From e50423991e56f1edb0954f2db066acd1f27b4ed7 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 16 Jun 2014 21:57:23 +0200
Subject: Add bow charging animation
---
src/Entities/Player.cpp | 6 +++++-
src/Entities/Player.h | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index fdc0bb390..978517086 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1,4 +1,4 @@
-
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Player.h"
@@ -411,6 +411,7 @@ void cPlayer::StartChargingBow(void)
LOGD("Player \"%s\" started charging their bow", GetName().c_str());
m_IsChargingBow = true;
m_BowCharge = 0;
+ m_World->BroadcastEntityMetadata(*this, m_ClientHandle);
}
@@ -423,6 +424,8 @@ int cPlayer::FinishChargingBow(void)
int res = m_BowCharge;
m_IsChargingBow = false;
m_BowCharge = 0;
+ m_World->BroadcastEntityMetadata(*this, m_ClientHandle);
+
return res;
}
@@ -435,6 +438,7 @@ void cPlayer::CancelChargingBow(void)
LOGD("Player \"%s\" cancelled charging their bow at a charge of %d", GetName().c_str(), m_BowCharge);
m_IsChargingBow = false;
m_BowCharge = 0;
+ m_World->BroadcastEntityMetadata(*this, m_ClientHandle);
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index b2142a18b..2f7957f16 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -404,7 +404,7 @@ public:
// cEntity overrides:
virtual bool IsCrouched (void) const { return m_IsCrouched; }
virtual bool IsSprinting(void) const { return m_IsSprinting; }
- virtual bool IsRclking (void) const { return IsEating(); }
+ virtual bool IsRclking (void) const { return IsEating() || IsChargingBow(); }
virtual void Detach(void);
--
cgit v1.2.3
From 885a50d77a26eea6619de681bf6ee746e79308cd Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 16 Jun 2014 22:57:13 +0200
Subject: Fix bow sound and creative arrow pickup.
---
src/Entities/ArrowEntity.cpp | 32 ++++++++++++++++++++++----------
src/Items/ItemBow.h | 17 ++++++++---------
2 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 8d2569125..bdbaaab0d 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -3,6 +3,7 @@
#include "Player.h"
#include "ArrowEntity.h"
#include "../Chunk.h"
+#include "FastRandom.h"
@@ -24,9 +25,9 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
SetYawFromSpeed();
SetPitchFromSpeed();
LOGD("Created arrow %d with speed {%.02f, %.02f, %.02f} and rot {%.02f, %.02f}",
- m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(),
- GetYaw(), GetPitch()
- );
+ m_UniqueID, GetSpeedX(), GetSpeedY(), GetSpeedZ(),
+ GetYaw(), GetPitch()
+ );
}
@@ -44,6 +45,10 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
m_bIsCollected(false),
m_HitBlockPos(0, 0, 0)
{
+ if (a_Player.IsGameModeCreative())
+ {
+ m_PickupState = psInCreative;
+ }
}
@@ -120,16 +125,23 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
void cArrowEntity::CollectedBy(cPlayer * a_Dest)
{
- if ((m_IsInGround) && (!m_bIsCollected) && (CanPickup(*a_Dest)))
+ if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest))
{
- int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
- if (NumAdded > 0) // Only play effects if there was space in inventory
+ if (m_PickupState == 1)
{
- m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest);
- // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- m_World->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
- m_bIsCollected = true;
+ int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
+ if (NumAdded == 0)
+ {
+ // No space in the inventory
+ return;
+ }
}
+
+ m_World->BroadcastCollectPickup((const cPickup &)*this, *a_Dest);
+ m_bIsCollected = true;
+
+ cFastRandom Random;
+ m_World->BroadcastSoundEffect("random.pop", (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8), (int)std::floor(GetPosZ() * 8), 0.2F, ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F);
}
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index e0ab339d3..a8fac13cc 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -46,20 +46,17 @@ public:
{
// Actual shot - produce the arrow with speed based on the ticks that the bow was charged
ASSERT(a_Player != NULL);
-
+
int BowCharge = a_Player->FinishChargingBow();
- double Force = (double)BowCharge / 20;
- Force = (Force * Force + 2 * Force) / 3; // This formula is used by the 1.6.2 client
+ double Force = (double)BowCharge / 20.0;
+ Force = (Force * Force + 2.0 * Force) / 3.0; // This formula is used by the 1.6.2 client
if (Force < 0.1)
{
// Too little force, ignore the shot
return;
}
- if (Force > 1)
- {
- Force = 1;
- }
-
+ Force = std::max(Force, 1.0);
+
// Create the arrow entity:
cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2);
if (Arrow == NULL)
@@ -71,8 +68,10 @@ public:
delete Arrow;
return;
}
+
+ cFastRandom Random;
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
- a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force);
+ a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F);
if (!a_Player->IsGameModeCreative())
{
--
cgit v1.2.3
From b45e85a6784861e225c7a4ecfd7838a6d32c7875 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 16 Jun 2014 22:57:27 +0200
Subject: This isn't needed
---
src/Items/ItemBow.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index a8fac13cc..a2f740ba7 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -70,7 +70,6 @@ public:
}
cFastRandom Random;
- a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F);
if (!a_Player->IsGameModeCreative())
--
cgit v1.2.3
From a1fd0b0335a5b19af29a4862f4d0ac39bec6887f Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 16 Jun 2014 23:41:23 +0200
Subject: Split Broadcast Sound Effect function call in multiple lines.
---
src/Entities/ArrowEntity.cpp | 18 ++++++++++++++++--
src/Items/ItemBow.h | 9 ++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index bdbaaab0d..7f2c8dca5 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -114,7 +114,14 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
// Broadcast successful hit sound
- m_World->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect(
+ "random.successful_hit",
+ (int)std::floor(GetPosX() * 8.0),
+ (int)std::floor(GetPosY() * 8.0),
+ (int)std::floor(GetPosZ() * 8.0),
+ 0.5,
+ (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)
+ );
Destroy();
}
@@ -141,7 +148,14 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest)
m_bIsCollected = true;
cFastRandom Random;
- m_World->BroadcastSoundEffect("random.pop", (int)std::floor(GetPosX() * 8.0), (int)std::floor(GetPosY() * 8), (int)std::floor(GetPosZ() * 8), 0.2F, ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F);
+ m_World->BroadcastSoundEffect(
+ "random.pop",
+ (int)std::floor(GetPosX() * 8.0),
+ (int)std::floor(GetPosY() * 8),
+ (int)std::floor(GetPosZ() * 8),
+ 0.2F,
+ ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F
+ );
}
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index a2f740ba7..d79fecd30 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -70,7 +70,14 @@ public:
}
cFastRandom Random;
- a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)std::floor(a_Player->GetPosX() * 8.0), (int)std::floor(a_Player->GetPosY() * 8.0), (int)std::floor(a_Player->GetPosZ() * 8.0), 1.0F, 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F);
+ a_Player->GetWorld()->BroadcastSoundEffect(
+ "random.bow",
+ (int)std::floor(a_Player->GetPosX() * 8.0),
+ (int)std::floor(a_Player->GetPosY() * 8.0),
+ (int)std::floor(a_Player->GetPosZ() * 8.0),
+ 1.0F,
+ 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F
+ );
if (!a_Player->IsGameModeCreative())
{
--
cgit v1.2.3
From d89f03b90c60c2aaae3f937f5b84dc3c8f2f6ad1 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 17 Jun 2014 12:43:45 +0200
Subject: Float, not Double
---
src/Entities/ArrowEntity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 7f2c8dca5..ea782940a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -119,7 +119,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
(int)std::floor(GetPosX() * 8.0),
(int)std::floor(GetPosY() * 8.0),
(int)std::floor(GetPosZ() * 8.0),
- 0.5,
+ 0.5F,
(float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)
);
--
cgit v1.2.3
From 37de63895f029342b92923d08585aa8f4fdae2ea Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 17 Jun 2014 12:45:12 +0200
Subject: The same: Float, not Double
---
src/Entities/ArrowEntity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index ea782940a..9a8571a31 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -120,7 +120,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
(int)std::floor(GetPosY() * 8.0),
(int)std::floor(GetPosZ() * 8.0),
0.5F,
- (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)
+ 0.75F + ((float)((GetUniqueID() * 23) % 32)) / 64F
);
Destroy();
--
cgit v1.2.3
From 8928310fd8308c583609edd1cb111276ffe79f8e Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Tue, 17 Jun 2014 13:27:04 +0200
Subject: Fixed possible confusion. If a command handler gets an error then the
player will receive an unknown command error. This can be confusing for
players.
---
src/Bindings/PluginManager.cpp | 8 +++++++-
src/Bindings/PluginManager.h | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 9bcd8e3b7..f9035e869 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1356,7 +1356,13 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
ASSERT(cmd->second.m_Plugin != NULL);
- return cmd->second.m_Plugin->HandleCommand(Split, a_Player);
+ if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
+ {
+ a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", Split[0].c_str()));
+ return true; // The command handler was found and executed, so we return true.
+ }
+
+ return true;
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index be40bd2f7..0b0498280 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -321,7 +321,7 @@ private:
/** Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. */
bool AddPlugin(cPlugin * a_Plugin);
- /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is handled. */
+ /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is executed. */
bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden);
bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
--
cgit v1.2.3
From ce06ec1632ffb15243e2270ed31632e8d3566f39 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 17 Jun 2014 13:33:41 +0200
Subject: derp
---
src/Entities/ArrowEntity.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 9a8571a31..e46d21515 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -119,8 +119,8 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
(int)std::floor(GetPosX() * 8.0),
(int)std::floor(GetPosY() * 8.0),
(int)std::floor(GetPosZ() * 8.0),
- 0.5F,
- 0.75F + ((float)((GetUniqueID() * 23) % 32)) / 64F
+ 0.5f,
+ 0.75f + ((float)((GetUniqueID() * 23) % 32)) / 64.0f
);
Destroy();
@@ -134,7 +134,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest)
{
if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest))
{
- if (m_PickupState == 1)
+ if (m_PickupState == psInSurvivalOrCreative)
{
int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
if (NumAdded == 0)
--
cgit v1.2.3
From 15ae4ce23371ec6bc1b1f61f4dd7c4ffbd1adf64 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Tue, 17 Jun 2014 14:55:15 +0200
Subject: HandleCommand now returns an CommandResult enum.
---
src/Bindings/PluginManager.cpp | 28 +++++++++++-----------------
src/Bindings/PluginManager.h | 14 ++++++++------
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index f9035e869..abbb05ae0 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -257,18 +257,13 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
- bool WasCommandForbidden = false;
- if (HandleCommand(a_Player, a_Message, true, WasCommandForbidden)) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool
+ if (HandleCommand(a_Player, a_Message, true) != crUnknownCommand) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool
{
return true; // Chat message was handled as command
}
- else if (WasCommandForbidden) // Couldn't be handled as command, was it because of insufficient permissions?
- {
- return true; // Yes - message was sent in HandleCommand, abort
- }
// Check if it was a standard command (starts with a slash)
- // If it was, we know that it was completely unrecognised (WasCommandForbidden == false)
+ // If it was, we know that it was completely unrecognised
if (!a_Message.empty() && (a_Message[0] == '/'))
{
AStringVector Split(StringSplit(a_Message, " "));
@@ -1318,28 +1313,28 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastT
-bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden)
+cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
ASSERT(a_Player != NULL);
AStringVector Split(StringSplit(a_Command, " "));
if (Split.empty())
{
- return false;
+ return crUnknownCommand;
}
CommandMap::iterator cmd = m_Commands.find(Split[0]);
if (cmd == m_Commands.end())
{
// Command not found
- return false;
+ return crUnknownCommand;
}
// Ask plugins first if a command is okay to execute the command:
if (CallHookExecuteCommand(a_Player, Split))
{
LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str());
- return false;
+ return crError;
}
if (
@@ -1350,8 +1345,7 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
{
a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str()));
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str());
- a_WasCommandForbidden = true;
- return false;
+ return crError;
}
ASSERT(cmd->second.m_Plugin != NULL);
@@ -1359,10 +1353,10 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
{
a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", Split[0].c_str()));
- return true; // The command handler was found and executed, so we return true.
+ return crError;
}
- return true;
+ return crExecuted;
}
@@ -1561,7 +1555,7 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command)
bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
- return HandleCommand(a_Player, a_Command, true);
+ return (HandleCommand(a_Player, a_Command, true) == crExecuted);
}
@@ -1570,7 +1564,7 @@ bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Comman
bool cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
- return HandleCommand(a_Player, a_Command, false);
+ return (HandleCommand(a_Player, a_Command, false) == crExecuted);
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 0b0498280..049e70b49 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -58,6 +58,13 @@ public: // tolua_export
// Called each tick
virtual void Tick(float a_Dt);
+ enum CommandResult
+ {
+ crExecuted,
+ crUnknownCommand,
+ crError,
+ } ;
+
// tolua_begin
enum PluginHook
{
@@ -322,12 +329,7 @@ private:
bool AddPlugin(cPlugin * a_Plugin);
/** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is executed. */
- bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions, bool & a_WasCommandForbidden);
- bool HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
- {
- bool DummyBoolean = false;
- return HandleCommand(a_Player, a_Command, a_ShouldCheckPermissions, DummyBoolean);
- }
+ cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
} ; // tolua_export
--
cgit v1.2.3
From 008a6ce311d3020927d5ef4b0d53905df48bcae5 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Tue, 17 Jun 2014 16:19:31 +0200
Subject: Added crBlocked and crNoPermission
---
src/Bindings/PluginManager.cpp | 4 ++--
src/Bindings/PluginManager.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index abbb05ae0..c317ae362 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1334,7 +1334,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
if (CallHookExecuteCommand(a_Player, Split))
{
LOGINFO("Player %s tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str());
- return crError;
+ return crBlocked;
}
if (
@@ -1345,7 +1345,7 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
{
a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str()));
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str());
- return crError;
+ return crNoPermission;
}
ASSERT(cmd->second.m_Plugin != NULL);
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 049e70b49..96b7a979b 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -63,6 +63,8 @@ public: // tolua_export
crExecuted,
crUnknownCommand,
crError,
+ crBlocked,
+ crNoPermission,
} ;
// tolua_begin
--
cgit v1.2.3
From c1692a2e3be114c2807fdaaea0fa4fcd3d4bbc5d Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 00:16:33 -0700
Subject: Added classes for splash potions and wither skulls
---
src/Entities/ProjectileEntity.cpp | 4 ++++
src/Entities/SplashPotionEntity.cpp | 37 ++++++++++++++++++++++++++++++++++
src/Entities/SplashPotionEntity.h | 34 +++++++++++++++++++++++++++++++
src/Entities/WitherSkullEntity.cpp | 40 +++++++++++++++++++++++++++++++++++++
src/Entities/WitherSkullEntity.h | 34 +++++++++++++++++++++++++++++++
5 files changed, 149 insertions(+)
create mode 100644 src/Entities/SplashPotionEntity.cpp
create mode 100644 src/Entities/SplashPotionEntity.h
create mode 100644 src/Entities/WitherSkullEntity.cpp
create mode 100644 src/Entities/WitherSkullEntity.h
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 95c494569..ee3890f23 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -18,9 +18,11 @@
#include "ThrownEnderPearlEntity.h"
#include "ExpBottleEntity.h"
#include "ThrownSnowballEntity.h"
+#include "SplashPotionEntity.h"
#include "FireChargeEntity.h"
#include "FireworkEntity.h"
#include "GhastFireballEntity.h"
+#include "WitherSkullEntity.h"
@@ -250,6 +252,8 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
case pkGhastFireball: return new cGhastFireballEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFireCharge: return new cFireChargeEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkSplashPotion: return new cSplashPotionEntity (a_Creator, a_X, a_Y, a_Z, Speed);
+ case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFirework:
{
if (a_Item.m_FireworkItem.m_Colours.empty())
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
new file mode 100644
index 000000000..c6be2baf7
--- /dev/null
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -0,0 +1,37 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "SplashPotionEntity.h"
+#include "../World.h"
+
+
+
+
+
+cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+{
+ // TODO: Apply potion effect to entities nearby
+ Destroy();
+}
+
+
+
+
+
+void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+{
+ a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
+
+ // TODO: Apply potion effect to entity and others nearby
+
+ Destroy(true);
+}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
new file mode 100644
index 000000000..d82a7bfcd
--- /dev/null
+++ b/src/Entities/SplashPotionEntity.h
@@ -0,0 +1,34 @@
+//
+// SplashPotionEntity.h
+//
+
+#pragma once
+
+#include "ProjectileEntity.h"
+
+
+
+
+
+// tolua_begin
+
+class cSplashPotionEntity :
+public cProjectileEntity
+{
+ typedef cProjectileEntity super;
+
+public:
+
+ // tolua_end
+
+ CLASS_PROTODEF(cSplashPotionEntity);
+
+ cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+
+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;
+
+} ; // tolua_export
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
new file mode 100644
index 000000000..ea78bba5d
--- /dev/null
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -0,0 +1,40 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "WitherSkullEntity.h"
+#include "../World.h"
+
+
+
+
+
+cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+{
+ // TODO: Explode
+ // TODO: Apply wither effect to entities nearby
+ Destroy();
+}
+
+
+
+
+
+void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+{
+ // TODO: If entity is Ender Crystal, destroy it
+ a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
+
+ // TODO: Explode
+ // TODO: Apply wither effect to entity and others nearby
+
+ Destroy(true);
+}
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
new file mode 100644
index 000000000..85ba55d4d
--- /dev/null
+++ b/src/Entities/WitherSkullEntity.h
@@ -0,0 +1,34 @@
+//
+// WitherSkullEntity.h
+//
+
+#pragma once
+
+#include "ProjectileEntity.h"
+
+
+
+
+
+// tolua_begin
+
+class cWitherSkullEntity :
+public cProjectileEntity
+{
+ typedef cProjectileEntity super;
+
+public:
+
+ // tolua_end
+
+ CLASS_PROTODEF(cWitherSkullEntity);
+
+ cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+
+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;
+
+} ; // tolua_export
--
cgit v1.2.3
From 87b1bfaf2aa62bf600293d11d0b3c73cfe9f9e33 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 00:17:49 -0700
Subject: Moved Effects.h to EntityEffects.h, added initial impl
---
src/Bindings/AllToLua.pkg | 2 +-
src/CMakeLists.txt | 2 +-
src/Entities/Effects.h | 30 ------------------------
src/Entities/EntityEffects.cpp | 25 ++++++++++++++++++++
src/Entities/EntityEffects.h | 53 ++++++++++++++++++++++++++++++++++++++++++
src/Entities/Pawn.cpp | 25 ++++++++++++++++++++
src/Entities/Pawn.h | 7 ++++++
src/Entities/Player.cpp | 6 ++---
src/Globals.h | 1 -
9 files changed, 115 insertions(+), 36 deletions(-)
delete mode 100644 src/Entities/Effects.h
create mode 100644 src/Entities/EntityEffects.cpp
create mode 100644 src/Entities/EntityEffects.h
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 4fe86e1c5..4a6eb7535 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/TNTEntity.h"
-$cfile "../Entities/Effects.h"
+$cfile "../Entities/EntityEffects.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 335ce8315..3d5a0e396 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,7 +42,7 @@ set(BINDING_DEPENDECIES
Cuboid.h
Defines.h
Enchantments.h
- Entities/Effects.h
+ Entities/EntityEffects.h
Entities/Entity.h
Entities/Floater.h
Entities/Pawn.h
diff --git a/src/Entities/Effects.h b/src/Entities/Effects.h
deleted file mode 100644
index baf3302fb..000000000
--- a/src/Entities/Effects.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-// tolua_begin
-enum ENUM_ENTITY_EFFECT
-{
- E_EFFECT_SPEED = 1,
- E_EFFECT_SLOWNESS = 2,
- E_EFFECT_HASTE = 3,
- E_EFFECT_MINING_FATIGUE = 4,
- E_EFFECT_STENGTH = 5,
- E_EFFECT_INSTANT_HEALTH = 6,
- E_EFFECT_INSTANT_DAMAGE = 7,
- E_EFFECT_JUMP_BOOST = 8,
- E_EFFECT_NAUSEA = 9,
- E_EFFECT_REGENERATION = 10,
- E_EFFECT_RESISTANCE = 11,
- E_EFFECT_FIRE_RESISTANCE = 12,
- E_EFFECT_WATER_BREATHING = 13,
- E_EFFECT_INVISIBILITY = 14,
- E_EFFECT_BLINDNESS = 15,
- E_EFFECT_NIGHT_VISION = 16,
- E_EFFECT_HUNGER = 17,
- E_EFFECT_WEAKNESS = 18,
- E_EFFECT_POISON = 19,
- E_EFFECT_WITHER = 20,
- E_EFFECT_HEALTH_BOOST = 21,
- E_EFFECT_ABSORPTION = 22,
- E_EFFECT_SATURATION = 23,
-} ;
-// tolua_end
diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp
new file mode 100644
index 000000000..3aa3fd1ed
--- /dev/null
+++ b/src/Entities/EntityEffects.cpp
@@ -0,0 +1,25 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "EntityEffects.h"
+
+
+
+
+
+cEntityEffect::cEntityEffect():
+ m_Ticks(0),
+ m_Intensity(0)
+{
+
+}
+
+
+
+
+
+cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity):
+ m_Ticks(a_Ticks),
+ m_Intensity(a_Intensity)
+{
+
+}
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
new file mode 100644
index 000000000..6ddd86b01
--- /dev/null
+++ b/src/Entities/EntityEffects.h
@@ -0,0 +1,53 @@
+#pragma once
+
+// tolua_begin
+class cEntityEffect {
+public:
+
+ /** All types of entity effects (numbers correspond to IDs) */
+ enum eType
+ {
+ efSpeed = 1,
+ efSlowness = 2,
+ efHaste = 3,
+ efMiningFatigue = 4,
+ efStrength = 5,
+ efInstantHealth = 6,
+ efInstantDamage = 7,
+ efJumpBoost = 8,
+ efNausia = 9,
+ efRegeneration = 10,
+ efResistance = 11,
+ efFireResistance = 12,
+ efWaterBreathing = 13,
+ efInvisibility = 14,
+ efBlindness = 15,
+ efNightVision = 16,
+ efHunger = 17,
+ efWeakness = 18,
+ efPoison = 19,
+ efWither = 20,
+ efHealthBoost = 21,
+ efAbsorption = 22,
+ efSaturation = 23,
+ } ;
+
+ /** The duration of the effect */
+ int m_Ticks;
+
+ /** How strong the effect will be applied */
+ short m_Intensity;
+
+ /**
+ * An empty entity effect
+ */
+ cEntityEffect();
+
+ /**
+ * An entity effect
+ * @param a_Ticks The duration of the effect
+ * @param a_Intensity How strong the effect will be applied
+ */
+ cEntityEffect(int a_Ticks, short a_Intensity);
+};
+// tolua_end
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index fffefd538..e1ddca27e 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -10,6 +10,7 @@
cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
: cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
, m_bBurnable(true)
+ , m_EntityEffects(std::map())
{
}
@@ -17,3 +18,27 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
+void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
+{
+
+
+ super::Tick(a_Dt, a_Chunk);
+}
+
+
+
+
+
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+{
+ m_EntityEffects[a_EffectType] = a_Effect;
+}
+
+
+
+
+
+void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
+{
+ m_EntityEffects.erase(a_EffectType);
+}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index e76337d86..7824a06f8 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -2,6 +2,7 @@
#pragma once
#include "Entity.h"
+#include "EntityEffects.h"
@@ -18,9 +19,15 @@ public:
CLASS_PROTODEF(cPawn);
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
+
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
+ void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
protected:
bool m_bBurnable;
+ std::map m_EntityEffects;
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index fdc0bb390..035973a16 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -584,12 +584,12 @@ void cPlayer::FoodPoison(int a_NumTicks)
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
if (!HasBeenFoodPoisoned)
{
- m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER);
+ m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger);
SendHealth();
}
else
{
- m_World->BroadcastEntityEffect(*this, E_EFFECT_HUNGER, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
+ m_World->BroadcastEntityEffect(*this, cEntityEffect::efHunger, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
}
}
@@ -1930,7 +1930,7 @@ void cPlayer::HandleFood(void)
}
else
{
- m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect.
+ m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); // Remove the "Hunger" effect.
}
// Apply food exhaustion that has accumulated:
diff --git a/src/Globals.h b/src/Globals.h
index c5768facf..e99333693 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -368,6 +368,5 @@ T Clamp(T a_Value, T a_Min, T a_Max)
#include "BiomeDef.h"
#include "BlockID.h"
#include "BlockInfo.h"
-#include "Entities/Effects.h"
--
cgit v1.2.3
From aa7b3f33b939e6a43af713549e7b3bf28d0f5ab5 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 19:09:33 -0700
Subject: cPawn: Remove unused m_bBurnable
---
src/Entities/Pawn.cpp | 1 -
src/Entities/Pawn.h | 1 -
2 files changed, 2 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index e1ddca27e..13934d943 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -9,7 +9,6 @@
cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
: cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
- , m_bBurnable(true)
, m_EntityEffects(std::map())
{
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 7824a06f8..a954f4a70 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -26,7 +26,6 @@ public:
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
protected:
- bool m_bBurnable;
std::map m_EntityEffects;
} ; // tolua_export
--
cgit v1.2.3
From 90145a95144a7895fe9a2d7bb1d5c7a192f3a0ad Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 20:02:39 -0700
Subject: Added iterator on tick to manage entity effect duration
---
src/Entities/Pawn.cpp | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 13934d943..95d1b113e 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -19,7 +19,22 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
{
-
+ // Iterate through this entity's applied effects
+ for (std::map::iterator iter = m_EntityEffects.begin();
+ iter != m_EntityEffects.end();
+ ++iter)
+ {
+ // Reduce the effect's duration
+ iter->second.m_Ticks--;
+
+ // Remove effect if duration has elapsed
+ if (iter->second.m_Ticks <= 0)
+ {
+ RemoveEntityEffect(iter->first);
+ }
+
+ // TODO: Check for discrepancies between client and server effect values
+ }
super::Tick(a_Dt, a_Chunk);
}
@@ -31,6 +46,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
m_EntityEffects[a_EffectType] = a_Effect;
+ //m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.m_Intensity, a_Effect.m_Ticks);
}
@@ -40,4 +56,5 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
{
m_EntityEffects.erase(a_EffectType);
+ //m_World->BroadcastRemoveEntityEffect(*this, a_EffectType);
}
--
cgit v1.2.3
From 481f05b011230cba42901df939306b803bd670b6 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 21:48:20 -0700
Subject: Entity effects: Added handlers for entity effects
Implemented hunger, instant health, damage, poison, regen
Added "template" entity effect implementations
---
src/Entities/Pawn.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++++++
src/Entities/Pawn.h | 2 ++
src/Entities/Player.cpp | 51 +++++++++++++++++++-------
src/Entities/Player.h | 3 ++
4 files changed, 138 insertions(+), 13 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 95d1b113e..1d2542d58 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -24,6 +24,9 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
iter != m_EntityEffects.end();
++iter)
{
+ // Apply entity effect
+ HandleEntityEffects(iter->first, iter->second);
+
// Reduce the effect's duration
iter->second.m_Ticks--;
@@ -58,3 +61,95 @@ void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
m_EntityEffects.erase(a_EffectType);
//m_World->BroadcastRemoveEntityEffect(*this, a_EffectType);
}
+
+
+
+
+
+void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+{
+ switch (a_EffectType)
+ {
+ // Default effect behaviors
+ case cEntityEffect::efInstantHealth:
+ {
+ // Base heal = 6, doubles for every increase in intensity
+ Heal(6 * std::pow(2, a_Effect.GetIntensity()));
+
+ // TODO: Harms undead
+ return;
+ }
+ case cEntityEffect::efInstantDamage:
+ {
+ // Base damage = 6, doubles for every increase in intensity
+ int damage = 6 * std::pow(2, a_Effect.GetIntensity());
+ TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
+
+ // TODO: Heals undead
+ return;
+ }
+ case cEntityEffect::efStrength:
+ {
+ // TODO: Implement me!
+ return;
+ }
+ case cEntityEffect::efWeakness:
+ {
+ // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage)
+ //double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
+
+ // TODO: Implement me!
+ // TODO: Weakened villager zombies can be turned back to villagers with the god apple
+ return;
+ }
+ case cEntityEffect::efRegeneration:
+ {
+ // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
+ int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1));
+
+ static short counter = 0;
+ if (++counter >= frequency)
+ {
+ Heal(1);
+ counter = 0;
+ }
+
+ // TODO: Doesn't effect undead
+ return;
+ }
+ case cEntityEffect::efPoison:
+ {
+ // Poison frequency = 25 ticks, divided by potion level (Poison II = 25 ticks)
+ int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
+
+ static short counter = 0;
+ if (++counter >= frequency)
+ {
+ // Cannot take poison damage when health is at 1
+ if (GetHealth() > 1)
+ {
+ TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0);
+ }
+ counter = 0;
+ }
+
+ // TODO: Doesn't effect undead or spiders
+ return;
+ }
+ case cEntityEffect::efFireResistance:
+ {
+ // TODO: Implement me!
+ return;
+ }
+ case cEntityEffect::efSpeed:
+ {
+ // TODO: Implement me!
+ return;
+ }
+ case cEntityEffect::efSlowness:
+ {
+ // TODO: Implement me!
+ return;
+ }
+ }
+}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index a954f4a70..f7d7213ff 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -27,6 +27,8 @@ public:
protected:
std::map m_EntityEffects;
+
+ virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 035973a16..95ee8b39d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -584,12 +584,11 @@ void cPlayer::FoodPoison(int a_NumTicks)
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
if (!HasBeenFoodPoisoned)
{
- m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger);
SendHealth();
}
else
{
- m_World->BroadcastEntityEffect(*this, cEntityEffect::efHunger, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
+ AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, 400)); // Give the player the "Hunger" effect for 20 seconds.
}
}
@@ -1887,6 +1886,43 @@ void cPlayer::TickBurning(cChunk & a_Chunk)
+void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+{
+ switch (a_EffectType)
+ {
+ // Effects whose behaviors are overridden
+ case cEntityEffect::efMiningFatigue:
+ {
+ // TODO: Implement me!
+ return;
+ }
+ case cEntityEffect::efHunger:
+ {
+ m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
+ return;
+ }
+ case cEntityEffect::efSaturation:
+ {
+ // Increase saturation 1 per tick, adds 1 for every increase in level
+ m_FoodSaturationLevel += (1 + a_Effect.GetIntensity());
+ return;
+ }
+
+ // Client-side-only effects
+ case cEntityEffect::efNausia:
+ case cEntityEffect::efNightVision:
+ {
+ return;
+ }
+ }
+
+ super::HandleEntityEffects(a_EffectType, a_Effect);
+}
+
+
+
+
+
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
@@ -1921,17 +1957,6 @@ void cPlayer::HandleFood(void)
}
}
}
-
- // Apply food poisoning food exhaustion:
- if (m_FoodPoisonedTicksRemaining > 0)
- {
- m_FoodPoisonedTicksRemaining--;
- m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
- }
- else
- {
- m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); // Remove the "Hunger" effect.
- }
// Apply food exhaustion that has accumulated:
if (m_FoodExhaustionLevel >= 4)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index b2142a18b..88f732096 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -526,6 +526,9 @@ protected:
/** Stops players from burning in creative mode */
virtual void TickBurning(cChunk & a_Chunk) override;
+ /** Called each tick to handle entity effects*/
+ virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
+
/** Called in each tick to handle food-related processing */
void HandleFood(void);
--
cgit v1.2.3
From 2123173202554487386697625342b7ba21744960 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 21:55:23 -0700
Subject: Player: Removed food-poisoning-specific code, set duration to 30
seconds
http://minecraft.gamepedia.com/Hunger#Behavior
---
src/Entities/Player.cpp | 21 +--------------------
src/Entities/Player.h | 7 +------
src/Items/ItemHandler.cpp | 2 +-
3 files changed, 3 insertions(+), 27 deletions(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 95ee8b39d..3a1ebf3f9 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -40,7 +40,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_FoodSaturationLevel(5)
, m_FoodTickTimer(0)
, m_FoodExhaustionLevel(0)
- , m_FoodPoisonedTicksRemaining(0)
, m_LastJumpHeight(0)
, m_LastGroundHeight(0)
, m_bTouchGround(false)
@@ -551,15 +550,6 @@ void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
-void cPlayer::SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining)
-{
- m_FoodPoisonedTicksRemaining = a_FoodPoisonedTicksRemaining;
-}
-
-
-
-
-
bool cPlayer::Feed(int a_Food, double a_Saturation)
{
if (m_FoodLevel >= MAX_FOOD_LEVEL)
@@ -580,16 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- bool HasBeenFoodPoisoned = (m_FoodPoisonedTicksRemaining > 0);
- m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
- if (!HasBeenFoodPoisoned)
- {
- SendHealth();
- }
- else
- {
- AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, 400)); // Give the player the "Hunger" effect for 20 seconds.
- }
+ AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks));
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 88f732096..83114a4dd 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -267,7 +267,6 @@ public:
double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; }
int GetFoodTickTimer (void) const { return m_FoodTickTimer; }
double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; }
- int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; }
/** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */
bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); }
@@ -276,7 +275,6 @@ public:
void SetFoodSaturationLevel (double a_FoodSaturationLevel);
void SetFoodTickTimer (int a_FoodTickTimer);
void SetFoodExhaustionLevel (double a_FoodExhaustionLevel);
- void SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining);
/** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */
bool Feed(int a_Food, double a_Saturation);
@@ -287,7 +285,7 @@ public:
m_FoodExhaustionLevel += a_Exhaustion;
}
- /** Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two */
+ /** Starts the food poisoning for the specified amount of ticks */
void FoodPoison(int a_NumTicks);
/** Returns true if the player is currently in the process of eating the currently equipped item */
@@ -442,9 +440,6 @@ protected:
/** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */
double m_FoodExhaustionLevel;
- /** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */
- int m_FoodPoisonedTicksRemaining;
-
float m_LastJumpHeight;
float m_LastGroundHeight;
bool m_bTouchGround;
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index d97f986ba..67740e860 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -577,7 +577,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
cFastRandom r1;
if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0)
{
- a_Player->FoodPoison(300);
+ a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds.
}
}
--
cgit v1.2.3
From a9a4c9c6b25438aaebdeef03c323e9aa4a0348c2 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 6 Jun 2014 23:05:29 -0700
Subject: EntityEffect: read-only getters, added user and distance modifier
fields
User: the pawn that uses or produces the entity effect (drinks/throws a potion)
Distance modifier: the potency modifier from splash potion effectivity radius
---
src/Entities/EntityEffects.cpp | 14 +++++++++-----
src/Entities/EntityEffects.h | 30 +++++++++++++++++++++++++-----
src/Entities/Player.cpp | 2 +-
3 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp
index 3aa3fd1ed..c74463bfa 100644
--- a/src/Entities/EntityEffects.cpp
+++ b/src/Entities/EntityEffects.cpp
@@ -1,14 +1,16 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "EntityEffects.h"
-
+#include "Pawn.h"
cEntityEffect::cEntityEffect():
m_Ticks(0),
- m_Intensity(0)
+ m_Intensity(0),
+ m_User(NULL),
+ m_DistanceModifier(1)
{
}
@@ -17,9 +19,11 @@ cEntityEffect::cEntityEffect():
-cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity):
+cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier):
m_Ticks(a_Ticks),
- m_Intensity(a_Intensity)
+ m_Intensity(a_Intensity),
+ m_User(a_User),
+ m_DistanceModifier(a_DistanceModifier)
{
-}
+}
\ No newline at end of file
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 6ddd86b01..2bda2e104 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -1,5 +1,7 @@
#pragma once
+class cPawn;
+
// tolua_begin
class cEntityEffect {
public:
@@ -35,8 +37,14 @@ public:
/** The duration of the effect */
int m_Ticks;
- /** How strong the effect will be applied */
- short m_Intensity;
+ /** Returns how strong the effect will be applied */
+ short GetIntensity() { return m_Intensity; }
+
+ /** Returns the pawn that used this entity effect */
+ cPawn *GetUser() { return m_User; }
+
+ /** Returns the distance modifier for affecting potency */
+ double GetDistanceModifier() { return m_DistanceModifier; }
/**
* An empty entity effect
@@ -45,9 +53,21 @@ public:
/**
* An entity effect
- * @param a_Ticks The duration of the effect
- * @param a_Intensity How strong the effect will be applied
+ * @param a_Ticks The duration of the effect
+ * @param a_Intensity How strong the effect will be applied
+ * @param a_User The pawn that used this entity effect
+ * @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1
*/
- cEntityEffect(int a_Ticks, short a_Intensity);
+ cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1);
+
+private:
+ /** How strong the effect will be applied */
+ short m_Intensity;
+
+ /** The pawn that used this entity effect */
+ cPawn *m_User;
+
+ /** The distance modifier for affecting potency */
+ double m_DistanceModifier;
};
// tolua_end
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 3a1ebf3f9..d075957fe 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks));
+ AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks, NULL));
}
--
cgit v1.2.3
From e98ffccd80ae05d09b40d5edd407428515b14406 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 00:54:03 -0700
Subject: Pawn: Enabled entity effect broadcast, added typedef
Typedef'd std::map to tEffectMap
---
src/Entities/Pawn.cpp | 7 ++++---
src/Entities/Pawn.h | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 1d2542d58..1f93e59fa 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Pawn.h"
+#include "../World.h"
@@ -20,7 +21,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
{
// Iterate through this entity's applied effects
- for (std::map::iterator iter = m_EntityEffects.begin();
+ for (tEffectMap::iterator iter = m_EntityEffects.begin();
iter != m_EntityEffects.end();
++iter)
{
@@ -49,7 +50,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
m_EntityEffects[a_EffectType] = a_Effect;
- //m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.m_Intensity, a_Effect.m_Ticks);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks);
}
@@ -59,7 +60,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
{
m_EntityEffects.erase(a_EffectType);
- //m_World->BroadcastRemoveEntityEffect(*this, a_EffectType);
+ m_World->BroadcastRemoveEntityEffect(*this, a_EffectType);
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index f7d7213ff..1a897c958 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -26,7 +26,8 @@ public:
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
protected:
- std::map m_EntityEffects;
+ typedef std::map tEffectMap;
+ tEffectMap m_EntityEffects;
virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
} ; // tolua_export
--
cgit v1.2.3
From 615152eb8c6c88083f7b9eac57ec07147f34a6d6 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 02:02:20 -0700
Subject: Pawn.cpp: fixed effect iterator BAD_ACCESS
Erasure was occurring before the iterator increased, causing a bad access. Solved by storing map pairs in variables and manually updating iterator before erasure.
Fixed mix-up in function arguments on food poisoning
---
src/Entities/Pawn.cpp | 21 +++++++++++++--------
src/Entities/Player.cpp | 2 +-
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 1f93e59fa..93f6a69bc 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -10,7 +10,7 @@
cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
: cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
- , m_EntityEffects(std::map())
+ , m_EntityEffects(tEffectMap())
{
}
@@ -21,20 +21,25 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
{
// Iterate through this entity's applied effects
- for (tEffectMap::iterator iter = m_EntityEffects.begin();
- iter != m_EntityEffects.end();
- ++iter)
+ for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
{
+ // Copies values to prevent pesky wrong accesses and erasures
+ cEntityEffect::eType effect_type = iter->first;
+ cEntityEffect &effect_values = iter->second;
+
// Apply entity effect
- HandleEntityEffects(iter->first, iter->second);
+ HandleEntityEffects(effect_type, effect_values);
// Reduce the effect's duration
- iter->second.m_Ticks--;
+ effect_values.m_Ticks--;
+
+ // Iterates (must be called before any possible erasure)
+ ++iter;
// Remove effect if duration has elapsed
- if (iter->second.m_Ticks <= 0)
+ if (effect_values.m_Ticks <= 0)
{
- RemoveEntityEffect(iter->first);
+ RemoveEntityEffect(effect_type);
}
// TODO: Check for discrepancies between client and server effect values
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index d075957fe..67449f800 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks, NULL));
+ AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(a_NumTicks, 0, NULL));
}
--
cgit v1.2.3
From 1eb04a48ee3ec4114adc4334e6fbcc7561834025 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 13:45:00 -0700
Subject: Implemented milk, added documentation to Pawn.h
---
src/ClientHandle.cpp | 6 +++---
src/Entities/Pawn.cpp | 20 ++++++++++++++++++++
src/Entities/Pawn.h | 15 +++++++++++++++
src/Entities/Player.cpp | 2 +-
src/Items/ItemHandler.cpp | 19 ++++++++++++++++++-
src/Items/ItemHandler.h | 3 +++
src/Items/ItemMilk.h | 26 ++++++++++++++++++++++++++
7 files changed, 86 insertions(+), 5 deletions(-)
create mode 100644 src/Items/ItemMilk.h
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index e4bb9d8e9..7b114b927 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_SHOOT_EAT:
{
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
- if (ItemHandler->IsFood())
+ if (ItemHandler->IsFood() || ItemHandler->IsDrinkable())
{
m_Player->AbortEating();
return;
@@ -1182,9 +1182,9 @@ 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() && !m_Player->IsGameModeCreative())
+ else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable()) && !m_Player->IsGameModeCreative())
{
- if (m_Player->IsSatiated())
+ if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable())
{
// The player is satiated, they cannot eat
return;
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 93f6a69bc..4c840e6e1 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -72,6 +72,26 @@ void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
+void cPawn::ClearEntityEffects()
+{
+ // Iterate through this entity's applied effects
+ for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
+ {
+ // Copy values to prevent pesky wrong erasures
+ cEntityEffect::eType effect_type = iter->first;
+
+ // Iterates (must be called before any possible erasure)
+ ++iter;
+
+ // Remove effect
+ RemoveEntityEffect(effect_type);
+ }
+}
+
+
+
+
+
void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
switch (a_EffectType)
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 1a897c958..857488901 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -22,13 +22,28 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ /** Applies an entity effect
+ * @param a_EffectType The entity effect to apply
+ * @param a_Effect The parameters of the effect
+ */
void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
+
+ /** Removes a currently applied entity effect
+ * @param a_EffectType The entity effect to remove
+ */
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
+
+ /** Removes all currently applied entity effects (used when drinking milk) */
+ void ClearEntityEffects();
protected:
typedef std::map tEffectMap;
tEffectMap m_EntityEffects;
+ /** Applies entity effect effects
+ * @param a_EffectType The selected entity effect
+ * @param a_Effect The parameters of the selected entity effect
+ */
virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 67449f800..b4b344584 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -552,7 +552,7 @@ void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
bool cPlayer::Feed(int a_Food, double a_Saturation)
{
- if (m_FoodLevel >= MAX_FOOD_LEVEL)
+ if (IsSatiated())
{
return false;
}
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 67740e860..83be87b9e 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -19,6 +19,7 @@
#include "ItemCloth.h"
#include "ItemComparator.h"
#include "ItemDoor.h"
+#include "ItemMilk.h"
#include "ItemDye.h"
#include "ItemEmptyMap.h"
#include "ItemFishingRod.h"
@@ -119,6 +120,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
case E_BLOCK_LILY_PAD: return new cItemLilypadHandler(a_ItemType);
case E_ITEM_MAP: return new cItemMapHandler();
+ case E_ITEM_MILK: return new cItemMilkHandler();
case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType);
case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType);
@@ -475,7 +477,6 @@ bool cItemHandler::IsFood(void)
case E_ITEM_BREAD:
case E_ITEM_RAW_PORKCHOP:
case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_MILK:
case E_ITEM_RAW_FISH:
case E_ITEM_COOKED_FISH:
case E_ITEM_COOKIE:
@@ -501,6 +502,22 @@ bool cItemHandler::IsFood(void)
+bool cItemHandler::IsDrinkable(void)
+{
+ switch (m_ItemType)
+ {
+ case E_ITEM_MILK:
+ {
+ return true;
+ }
+ } // switch (m_ItemType)
+ return false;
+}
+
+
+
+
+
bool cItemHandler::IsPlaceable(void)
{
// We can place any block that has a corresponding E_BLOCK_TYPE:
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index e13198cd7..3a25a3f9d 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -82,6 +82,9 @@ public:
/** Indicates if this item is food */
virtual bool IsFood(void);
+ /** Indicates if this item is drinkable */
+ virtual bool IsDrinkable(void);
+
/** Blocks simply get placed */
virtual bool IsPlaceable(void);
diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h
new file mode 100644
index 000000000..8569c8cbe
--- /dev/null
+++ b/src/Items/ItemMilk.h
@@ -0,0 +1,26 @@
+
+#pragma once
+
+class cItemMilkHandler:
+ public cItemHandler
+{
+ typedef cItemHandler super;
+public:
+ cItemMilkHandler():
+ super(E_ITEM_MILK)
+ {
+ }
+
+ virtual bool IsDrinkable(void) override
+ {
+ return true;
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ a_Player->ClearEntityEffects();
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ a_Player->GetInventory().AddItem(E_ITEM_BUCKET);
+ return true;
+ }
+};
--
cgit v1.2.3
From 2185c72c2ca2d66b238d7d3234c173bd820d32ac Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 16:32:37 -0700
Subject: Implemented drinkable potions, noeffect entity effect,
Clears entity effects on death
---
src/ClientHandle.cpp | 6 +-
src/Entities/EntityEffects.h | 1 +
src/Entities/Pawn.cpp | 14 +++++
src/Entities/Pawn.h | 1 +
src/Items/ItemHandler.cpp | 6 +-
src/Items/ItemHandler.h | 2 +-
src/Items/ItemMilk.h | 4 +-
src/Items/ItemPotion.h | 137 +++++++++++++++++++++++++++++++++++++++++++
8 files changed, 165 insertions(+), 6 deletions(-)
create mode 100644 src/Items/ItemPotion.h
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 7b114b927..ab36bff91 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_SHOOT_EAT:
{
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
- if (ItemHandler->IsFood() || ItemHandler->IsDrinkable())
+ if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem()))
{
m_Player->AbortEating();
return;
@@ -1182,9 +1182,9 @@ 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() || ItemHandler->IsDrinkable()) && !m_Player->IsGameModeCreative())
+ else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative())
{
- if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable())
+ if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped))
{
// The player is satiated, they cannot eat
return;
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 2bda2e104..137eb6480 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -9,6 +9,7 @@ public:
/** All types of entity effects (numbers correspond to IDs) */
enum eType
{
+ efNoEffect = 0,
efSpeed = 1,
efSlowness = 2,
efHaste = 3,
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 4c840e6e1..5cf270006 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -52,8 +52,22 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
+void cPawn::KilledBy(cEntity *a_Killer)
+{
+ ClearEntityEffects();
+}
+
+
+
+
+
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
+ if (a_EffectType == cEntityEffect::efNoEffect)
+ {
+ return;
+ }
+
m_EntityEffects[a_EffectType] = a_Effect;
m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks);
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 857488901..47fb691f4 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -21,6 +21,7 @@ public:
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void KilledBy(cEntity * a_Killer) override;
/** Applies an entity effect
* @param a_EffectType The entity effect to apply
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 83be87b9e..f847c8ffa 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -35,6 +35,7 @@
#include "ItemNetherWart.h"
#include "ItemPainting.h"
#include "ItemPickaxe.h"
+#include "ItemPotion.h"
#include "ItemThrowable.h"
#include "ItemRedstoneDust.h"
#include "ItemRedstoneRepeater.h"
@@ -124,6 +125,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType);
case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType);
+ case E_ITEM_POTIONS: return new cItemPotionHandler();
case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType);
case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType);
case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemType);
@@ -502,8 +504,10 @@ bool cItemHandler::IsFood(void)
-bool cItemHandler::IsDrinkable(void)
+bool cItemHandler::IsDrinkable(const cItem * a_Item)
{
+ UNUSED(a_Item);
+
switch (m_ItemType)
{
case E_ITEM_MILK:
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index 3a25a3f9d..ead2c9769 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -83,7 +83,7 @@ public:
virtual bool IsFood(void);
/** Indicates if this item is drinkable */
- virtual bool IsDrinkable(void);
+ virtual bool IsDrinkable(const cItem * a_Item);
/** Blocks simply get placed */
virtual bool IsPlaceable(void);
diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h
index 8569c8cbe..62506a223 100644
--- a/src/Items/ItemMilk.h
+++ b/src/Items/ItemMilk.h
@@ -11,13 +11,15 @@ public:
{
}
- virtual bool IsDrinkable(void) override
+ virtual bool IsDrinkable(const cItem * a_Item) override
{
+ UNUSED(a_Item);
return true;
}
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
+ UNUSED(a_Item);
a_Player->ClearEntityEffects();
a_Player->GetInventory().RemoveOneEquippedItem();
a_Player->GetInventory().AddItem(E_ITEM_BUCKET);
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
new file mode 100644
index 000000000..e34b251aa
--- /dev/null
+++ b/src/Items/ItemPotion.h
@@ -0,0 +1,137 @@
+
+#pragma once
+
+#include "../Entities/EntityEffects.h"
+
+class cItemPotionHandler:
+public cItemHandler
+{
+ typedef cItemHandler super;
+
+ cEntityEffect::eType GetEntityEffectType(short a_ItemDamage)
+ {
+ // Potion effect bits are different from entity effect values
+ // For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits
+ switch (a_ItemDamage & 15)
+ {
+ case 1: return cEntityEffect::efRegeneration;
+ case 2: return cEntityEffect::efSpeed;
+ case 3: return cEntityEffect::efFireResistance;
+ case 4: return cEntityEffect::efPoison;
+ case 5: return cEntityEffect::efInstantHealth;
+ case 6: return cEntityEffect::efNightVision;
+ case 8: return cEntityEffect::efWeakness;
+ case 9: return cEntityEffect::efStrength;
+ case 10: return cEntityEffect::efSlowness;
+ case 12: return cEntityEffect::efInstantDamage;
+ case 13: return cEntityEffect::efWaterBreathing;
+ case 14: return cEntityEffect::efInvisibility;
+
+ // No effect potions
+ case 0:
+ case 7:
+ case 11:
+ case 15:
+ {
+ break;
+ }
+ }
+
+ return cEntityEffect::efNoEffect;
+ }
+
+ short GetEntityEffectIntensity(short a_ItemDamage)
+ {
+ // Level II potion if fifth bit is set
+ if (a_ItemDamage & 32) return 1;
+ else return 0;
+ }
+
+ int GetEntityEffectDuration(short a_ItemDamage)
+ {
+ // Base duration in ticks
+ int base = 0;
+ double tier_multi = 1, ext_multi = 1, splash_multi = 1;
+
+ switch (GetEntityEffectType(a_ItemDamage))
+ {
+ case cEntityEffect::efRegeneration:
+ case cEntityEffect::efPoison:
+ {
+ base = 900;
+ break;
+ }
+
+ case cEntityEffect::efSpeed:
+ case cEntityEffect::efFireResistance:
+ case cEntityEffect::efNightVision:
+ case cEntityEffect::efStrength:
+ case cEntityEffect::efWaterBreathing:
+ case cEntityEffect::efInvisibility:
+ {
+ base = 3600;
+ break;
+ }
+
+ case cEntityEffect::efWeakness:
+ case cEntityEffect::efSlowness:
+ {
+ base = 1800;
+ break;
+ }
+ }
+
+ // If potion is level 2, half the duration. If not, stays the same
+ tier_multi = GetEntityEffectIntensity(a_ItemDamage) > 0 ? 0.5 : 1;
+
+ // If potion is extended, multiply duration by 8/3. If not, stays the same
+ // Extended potion if sixth bit is set
+ ext_multi = a_ItemDamage & 64 ? (8.0/3.0) : 1;
+
+ // If potion is splash potion, multiply duration by 3/4. If not, stays the same
+ splash_multi = !IsDrinkable(a_ItemDamage) ? 0.75 : 1;
+
+ // For reference: http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit
+ // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
+ // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
+
+ return base * tier_multi * ext_multi * splash_multi;
+ }
+
+ bool IsDrinkable(short a_ItemDamage)
+ {
+ // Drinkable potion if 13th bit is set
+ // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return a_ItemDamage & 8192;
+ }
+
+public:
+ cItemPotionHandler():
+ super(E_ITEM_POTIONS)
+ {
+ }
+
+ virtual bool IsDrinkable(const cItem * a_Item) override
+ {
+ return IsDrinkable(a_Item->m_ItemDamage);
+ }
+
+ 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
+ {
+ // Called when potion is a splash potion
+ return true;
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ // Called when potion is a drinkable potion
+ short potion_damage = a_Item->m_ItemDamage;
+ a_Player->AddEntityEffect(GetEntityEffectType(potion_damage),
+ cEntityEffect(GetEntityEffectDuration(potion_damage),
+ GetEntityEffectIntensity(potion_damage),
+ a_Player));
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
+ return true;
+ }
+};
--
cgit v1.2.3
From 8eceaf9b0cadbc253e46cdcbf8a7b5e8d6070846 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 18:48:33 -0700
Subject: Player: made healing instantaneous
---
src/Entities/Entity.h | 2 +-
src/Entities/Player.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 2df66e353..b8f1f4c1c 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -315,7 +315,7 @@ public:
virtual void Killed(cEntity * a_Victim) {}
/// Heals the specified amount of HPs
- void Heal(int a_HitPoints);
+ virtual void Heal(int a_HitPoints);
/// Returns the health of this entity
int GetHealth(void) const { return m_Health; }
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 83114a4dd..3aba3289d 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -261,7 +261,7 @@ public:
void TossPickup(const cItem & a_Item);
/** Heals the player by the specified amount of HPs (positive only); sends health update */
- void Heal(int a_Health);
+ virtual void Heal(int a_Health) override;
int GetFoodLevel (void) const { return m_FoodLevel; }
double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; }
--
cgit v1.2.3
From 5803094d7d0a852568c45c450dc2cc52e6c7d681 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 19:58:41 -0700
Subject: Entity: only fire critical hit if damage type is physical
---
src/Entities/Entity.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index ee7ce06ac..ba829bf6b 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -310,7 +310,8 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cPlayer * Player = (cPlayer *)a_TDI.Attacker;
// IsOnGround() only is false if the player is moving downwards
- if (!Player->IsOnGround()) // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
+ // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
+ if (!Player->IsOnGround() && (a_TDI.DamageType == dtAttack || a_TDI.DamageType == dtArrowAttack))
{
a_TDI.FinalDamage += 2;
m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
--
cgit v1.2.3
From 58f35af6e71f11844b9c6c1d1ebd2d7390439cca Mon Sep 17 00:00:00 2001
From: archshift
Date: Sat, 7 Jun 2014 21:56:01 -0700
Subject: Added splash potion functionality
---
src/Entities/EntityEffects.h | 4 +++
src/Entities/Pawn.cpp | 7 +++--
src/Entities/ProjectileEntity.cpp | 2 --
src/Entities/SplashPotionEntity.cpp | 58 +++++++++++++++++++++++++++++++++----
src/Entities/SplashPotionEntity.h | 30 +++++++++++++++++--
src/Items/ItemPotion.h | 36 ++++++++++++++++++++++-
6 files changed, 122 insertions(+), 15 deletions(-)
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 137eb6480..e6b5bdd5d 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -47,6 +47,10 @@ public:
/** Returns the distance modifier for affecting potency */
double GetDistanceModifier() { return m_DistanceModifier; }
+ void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
+ void SetUser(cPawn *a_User) { m_User = a_User; }
+ void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
+
/**
* An empty entity effect
*/
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 5cf270006..5cd493a06 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -69,7 +69,8 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
}
m_EntityEffects[a_EffectType] = a_Effect;
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(),
+ a_Effect.m_Ticks * a_Effect.GetDistanceModifier());
}
@@ -114,7 +115,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
case cEntityEffect::efInstantHealth:
{
// Base heal = 6, doubles for every increase in intensity
- Heal(6 * std::pow(2, a_Effect.GetIntensity()));
+ Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
// TODO: Harms undead
return;
@@ -123,7 +124,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
{
// Base damage = 6, doubles for every increase in intensity
int damage = 6 * std::pow(2, a_Effect.GetIntensity());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
+ TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0);
// TODO: Heals undead
return;
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index ee3890f23..664f929f6 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -18,7 +18,6 @@
#include "ThrownEnderPearlEntity.h"
#include "ExpBottleEntity.h"
#include "ThrownSnowballEntity.h"
-#include "SplashPotionEntity.h"
#include "FireChargeEntity.h"
#include "FireworkEntity.h"
#include "GhastFireballEntity.h"
@@ -252,7 +251,6 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
case pkGhastFireball: return new cGhastFireballEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFireCharge: return new cFireChargeEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed);
- case pkSplashPotion: return new cSplashPotionEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFirework:
{
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index c6be2baf7..5dcea2385 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -1,14 +1,17 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "SplashPotionEntity.h"
-#include "../World.h"
+#include "Player.h"
-cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
-super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName) :
+ super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_EntityEffectType(a_EntityEffectType),
+ m_EntityEffect(a_EntityEffect),
+ m_PotionName(a_PotionName)
{
SetSpeed(a_Speed);
}
@@ -19,7 +22,7 @@ super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- // TODO: Apply potion effect to entities nearby
+ Splash(a_HitPos);
Destroy();
}
@@ -30,8 +33,51 @@ void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace
void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
+ Splash(a_HitPos);
+ Destroy(true);
+}
+
+
+
+
+
+void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
+{
+ cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
+ m_World->ForEachPlayer(Callback);
+ // TODO: Should be for each pawn
- // TODO: Apply potion effect to entity and others nearby
+ m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName);
+}
+
+
+
+
+
+cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect):
+ m_HitPos(a_HitPos),
+ m_EntityEffectType(a_EntityEffectType),
+ m_EntityEffect(a_EntityEffect)
+{
- Destroy(true);
+}
+
+
+
+
+
+bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player)
+{
+ double distance_splash = (a_Player->GetPosition() - m_HitPos).Length();
+ if (distance_splash < 20)
+ {
+ // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
+ // TODO: better equation
+ double reduction = -0.25 * distance_splash + 1.0;
+ if (reduction < 0) reduction = 0;
+
+ m_EntityEffect.SetDistanceModifier(reduction);
+ a_Player->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
+ }
+ return false;
}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index d82a7bfcd..b64b668a5 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -5,7 +5,8 @@
#pragma once
#include "ProjectileEntity.h"
-
+#include "EntityEffects.h"
+#include "../World.h"
@@ -13,7 +14,7 @@
// tolua_begin
class cSplashPotionEntity :
-public cProjectileEntity
+ public cProjectileEntity
{
typedef cProjectileEntity super;
@@ -23,7 +24,7 @@ public:
CLASS_PROTODEF(cSplashPotionEntity);
- cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName);
protected:
@@ -31,4 +32,27 @@ protected:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ /** Splashes the potion, fires its particle effects and sounds
+ * @param a_HitPos The position where the potion will splash
+ */
+ void Splash(const Vector3d & a_HitPos);
+
+ cEntityEffect::eType m_EntityEffectType;
+ cEntityEffect m_EntityEffect;
+ int m_PotionName;
+
+ class cSplashPotionCallback :
+ public cPlayerListCallback
+ {
+ public:
+ cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect);
+
+ virtual bool Item(cPlayer * a_Player) override;
+
+ private:
+ const Vector3d &m_HitPos;
+ cEntityEffect::eType &m_EntityEffectType;
+ cEntityEffect &m_EntityEffect;
+ };
+
} ; // tolua_export
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index e34b251aa..528268cfe 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -2,12 +2,18 @@
#pragma once
#include "../Entities/EntityEffects.h"
+#include "../Entities/SplashPotionEntity.h"
class cItemPotionHandler:
-public cItemHandler
+ public cItemHandler
{
typedef cItemHandler super;
+ int GetPotionName(short a_ItemDamage)
+ {
+ return a_ItemDamage & 63;
+ }
+
cEntityEffect::eType GetEntityEffectType(short a_ItemDamage)
{
// Potion effect bits are different from entity effect values
@@ -118,6 +124,34 @@ public:
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
{
+ Vector3d Speed = a_Player->GetLookVector() * 10;
+
+ short potion_damage = a_Item.m_ItemDamage;
+ cProjectileEntity * Projectile = new cSplashPotionEntity(a_Player,
+ (double)a_BlockX,
+ (double)a_BlockY,
+ (double)a_BlockZ,
+ &Speed,
+ GetEntityEffectType(potion_damage),
+ cEntityEffect(GetEntityEffectDuration(potion_damage),
+ GetEntityEffectIntensity(potion_damage),
+ a_Player),
+ GetPotionName(potion_damage));
+ if (Projectile == NULL)
+ {
+ return false;
+ }
+ if (!Projectile->Initialize(*a_World))
+ {
+ delete Projectile;
+ return false;
+ }
+
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+
// Called when potion is a splash potion
return true;
}
--
cgit v1.2.3
From 73cea7065db458da7704917788ac80b75e042d6e Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 03:27:22 -0700
Subject: Entity effect type: use 'eff' as a prefix instead of 'ef'
---
src/Entities/EntityEffects.h | 48 +++++++++++++--------------
src/Entities/Pawn.cpp | 20 ++++++------
src/Entities/Player.cpp | 12 +++----
src/Entities/WitherSkullEntity.cpp | 2 +-
src/Items/ItemPotion.h | 66 +++++++++++++++++++-------------------
5 files changed, 74 insertions(+), 74 deletions(-)
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index e6b5bdd5d..26d2c92e5 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -9,30 +9,30 @@ public:
/** All types of entity effects (numbers correspond to IDs) */
enum eType
{
- efNoEffect = 0,
- efSpeed = 1,
- efSlowness = 2,
- efHaste = 3,
- efMiningFatigue = 4,
- efStrength = 5,
- efInstantHealth = 6,
- efInstantDamage = 7,
- efJumpBoost = 8,
- efNausia = 9,
- efRegeneration = 10,
- efResistance = 11,
- efFireResistance = 12,
- efWaterBreathing = 13,
- efInvisibility = 14,
- efBlindness = 15,
- efNightVision = 16,
- efHunger = 17,
- efWeakness = 18,
- efPoison = 19,
- efWither = 20,
- efHealthBoost = 21,
- efAbsorption = 22,
- efSaturation = 23,
+ effNoEffect = 0,
+ effSpeed = 1,
+ effSlowness = 2,
+ effHaste = 3,
+ effMiningFatigue = 4,
+ effStrength = 5,
+ effInstantHealth = 6,
+ effInstantDamage = 7,
+ effJumpBoost = 8,
+ effNausea = 9,
+ effRegeneration = 10,
+ effResistance = 11,
+ effFireResistance = 12,
+ effWaterBreathing = 13,
+ effInvisibility = 14,
+ effBlindness = 15,
+ effNightVision = 16,
+ effHunger = 17,
+ effWeakness = 18,
+ effPoison = 19,
+ effWither = 20,
+ effHealthBoost = 21,
+ effAbsorption = 22,
+ effSaturation = 23,
} ;
/** The duration of the effect */
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 5cd493a06..a1f24138d 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -63,7 +63,7 @@ void cPawn::KilledBy(cEntity *a_Killer)
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
- if (a_EffectType == cEntityEffect::efNoEffect)
+ if (a_EffectType == cEntityEffect::effNoEffect)
{
return;
}
@@ -112,7 +112,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
switch (a_EffectType)
{
// Default effect behaviors
- case cEntityEffect::efInstantHealth:
+ case cEntityEffect::effInstantHealth:
{
// Base heal = 6, doubles for every increase in intensity
Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
@@ -120,7 +120,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
// TODO: Harms undead
return;
}
- case cEntityEffect::efInstantDamage:
+ case cEntityEffect::effInstantDamage:
{
// Base damage = 6, doubles for every increase in intensity
int damage = 6 * std::pow(2, a_Effect.GetIntensity());
@@ -129,12 +129,12 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
// TODO: Heals undead
return;
}
- case cEntityEffect::efStrength:
+ case cEntityEffect::effStrength:
{
// TODO: Implement me!
return;
}
- case cEntityEffect::efWeakness:
+ case cEntityEffect::effWeakness:
{
// Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage)
//double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
@@ -143,7 +143,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
// TODO: Weakened villager zombies can be turned back to villagers with the god apple
return;
}
- case cEntityEffect::efRegeneration:
+ case cEntityEffect::effRegeneration:
{
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1));
@@ -158,7 +158,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
// TODO: Doesn't effect undead
return;
}
- case cEntityEffect::efPoison:
+ case cEntityEffect::effPoison:
{
// Poison frequency = 25 ticks, divided by potion level (Poison II = 25 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
@@ -177,17 +177,17 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
// TODO: Doesn't effect undead or spiders
return;
}
- case cEntityEffect::efFireResistance:
+ case cEntityEffect::effFireResistance:
{
// TODO: Implement me!
return;
}
- case cEntityEffect::efSpeed:
+ case cEntityEffect::effSpeed:
{
// TODO: Implement me!
return;
}
- case cEntityEffect::efSlowness:
+ case cEntityEffect::effSlowness:
{
// TODO: Implement me!
return;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index b4b344584..6bceab26f 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(a_NumTicks, 0, NULL));
+ AddEntityEffect(cEntityEffect::effHunger, cEntityEffect(a_NumTicks, 0, NULL));
}
@@ -1872,17 +1872,17 @@ void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffe
switch (a_EffectType)
{
// Effects whose behaviors are overridden
- case cEntityEffect::efMiningFatigue:
+ case cEntityEffect::effMiningFatigue:
{
// TODO: Implement me!
return;
}
- case cEntityEffect::efHunger:
+ case cEntityEffect::effHunger:
{
m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
return;
}
- case cEntityEffect::efSaturation:
+ case cEntityEffect::effSaturation:
{
// Increase saturation 1 per tick, adds 1 for every increase in level
m_FoodSaturationLevel += (1 + a_Effect.GetIntensity());
@@ -1890,8 +1890,8 @@ void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffe
}
// Client-side-only effects
- case cEntityEffect::efNausia:
- case cEntityEffect::efNightVision:
+ case cEntityEffect::effNausea:
+ case cEntityEffect::effNightVision:
{
return;
}
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
index ea78bba5d..03e36a3f4 100644
--- a/src/Entities/WitherSkullEntity.cpp
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -8,7 +8,7 @@
cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
-super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
{
SetSpeed(a_Speed);
}
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 528268cfe..4c67e9dc7 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -20,18 +20,18 @@ class cItemPotionHandler:
// For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits
switch (a_ItemDamage & 15)
{
- case 1: return cEntityEffect::efRegeneration;
- case 2: return cEntityEffect::efSpeed;
- case 3: return cEntityEffect::efFireResistance;
- case 4: return cEntityEffect::efPoison;
- case 5: return cEntityEffect::efInstantHealth;
- case 6: return cEntityEffect::efNightVision;
- case 8: return cEntityEffect::efWeakness;
- case 9: return cEntityEffect::efStrength;
- case 10: return cEntityEffect::efSlowness;
- case 12: return cEntityEffect::efInstantDamage;
- case 13: return cEntityEffect::efWaterBreathing;
- case 14: return cEntityEffect::efInvisibility;
+ case 1: return cEntityEffect::effRegeneration;
+ case 2: return cEntityEffect::effSpeed;
+ case 3: return cEntityEffect::effFireResistance;
+ case 4: return cEntityEffect::effPoison;
+ case 5: return cEntityEffect::effInstantHealth;
+ case 6: return cEntityEffect::effNightVision;
+ case 8: return cEntityEffect::effWeakness;
+ case 9: return cEntityEffect::effStrength;
+ case 10: return cEntityEffect::effSlowness;
+ case 12: return cEntityEffect::effInstantDamage;
+ case 13: return cEntityEffect::effWaterBreathing;
+ case 14: return cEntityEffect::effInvisibility;
// No effect potions
case 0:
@@ -43,7 +43,7 @@ class cItemPotionHandler:
}
}
- return cEntityEffect::efNoEffect;
+ return cEntityEffect::effNoEffect;
}
short GetEntityEffectIntensity(short a_ItemDamage)
@@ -61,26 +61,26 @@ class cItemPotionHandler:
switch (GetEntityEffectType(a_ItemDamage))
{
- case cEntityEffect::efRegeneration:
- case cEntityEffect::efPoison:
+ case cEntityEffect::effRegeneration:
+ case cEntityEffect::effPoison:
{
base = 900;
break;
}
- case cEntityEffect::efSpeed:
- case cEntityEffect::efFireResistance:
- case cEntityEffect::efNightVision:
- case cEntityEffect::efStrength:
- case cEntityEffect::efWaterBreathing:
- case cEntityEffect::efInvisibility:
+ case cEntityEffect::effSpeed:
+ case cEntityEffect::effFireResistance:
+ case cEntityEffect::effNightVision:
+ case cEntityEffect::effStrength:
+ case cEntityEffect::effWaterBreathing:
+ case cEntityEffect::effInvisibility:
{
base = 3600;
break;
}
- case cEntityEffect::efWeakness:
- case cEntityEffect::efSlowness:
+ case cEntityEffect::effWeakness:
+ case cEntityEffect::effSlowness:
{
base = 1800;
break;
@@ -127,16 +127,16 @@ public:
Vector3d Speed = a_Player->GetLookVector() * 10;
short potion_damage = a_Item.m_ItemDamage;
- cProjectileEntity * Projectile = new cSplashPotionEntity(a_Player,
- (double)a_BlockX,
- (double)a_BlockY,
- (double)a_BlockZ,
- &Speed,
- GetEntityEffectType(potion_damage),
- cEntityEffect(GetEntityEffectDuration(potion_damage),
- GetEntityEffectIntensity(potion_damage),
- a_Player),
- GetPotionName(potion_damage));
+ cSplashPotionEntity * Projectile = new cSplashPotionEntity(a_Player,
+ (double)a_BlockX,
+ (double)a_BlockY,
+ (double)a_BlockZ,
+ &Speed,
+ GetEntityEffectType(potion_damage),
+ cEntityEffect(GetEntityEffectDuration(potion_damage),
+ GetEntityEffectIntensity(potion_damage),
+ a_Player),
+ GetPotionName(potion_damage));
if (Projectile == NULL)
{
return false;
--
cgit v1.2.3
From a1a8b7c0eee2189dfc129eb366edb43a315749f9 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 16:31:18 -0700
Subject: Splash potion: Adjusted speed, fixed spawn position
---
src/Items/ItemPotion.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 4c67e9dc7..029bb52cd 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -124,14 +124,11 @@ public:
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
{
- Vector3d Speed = a_Player->GetLookVector() * 10;
+ Vector3d Pos = a_Player->GetThrowStartPos();
+ Vector3d Speed = a_Player->GetLookVector() * 7;
short potion_damage = a_Item.m_ItemDamage;
- cSplashPotionEntity * Projectile = new cSplashPotionEntity(a_Player,
- (double)a_BlockX,
- (double)a_BlockY,
- (double)a_BlockZ,
- &Speed,
+ cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed,
GetEntityEffectType(potion_damage),
cEntityEffect(GetEntityEffectDuration(potion_damage),
GetEntityEffectIntensity(potion_damage),
--
cgit v1.2.3
From 3766ac96d77329c679d01d1ab1a846384acab42f Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 17:06:15 -0700
Subject: ItemHandler: changed IsDrinkable() to take a short argument
---
src/ClientHandle.cpp | 7 ++++---
src/Items/ItemHandler.cpp | 4 ++--
src/Items/ItemHandler.h | 4 ++--
src/Items/ItemMilk.h | 4 ++--
src/Items/ItemPotion.h | 13 ++++---------
5 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index ab36bff91..9443cf2c9 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_SHOOT_EAT:
{
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
- if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem()))
+ if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage))
{
m_Player->AbortEating();
return;
@@ -1176,15 +1176,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
return;
}
+ short EquippedDamage = Equipped.m_ItemDamage;
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType);
if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE))
{
HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
}
- else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative())
+ else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative())
{
- if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped))
+ if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage))
{
// The player is satiated, they cannot eat
return;
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index f847c8ffa..3d13af3a7 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -504,9 +504,9 @@ bool cItemHandler::IsFood(void)
-bool cItemHandler::IsDrinkable(const cItem * a_Item)
+bool cItemHandler::IsDrinkable(short a_ItemDamage)
{
- UNUSED(a_Item);
+ UNUSED(a_ItemDamage);
switch (m_ItemType)
{
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index ead2c9769..cffca11ab 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -83,7 +83,7 @@ public:
virtual bool IsFood(void);
/** Indicates if this item is drinkable */
- virtual bool IsDrinkable(const cItem * a_Item);
+ virtual bool IsDrinkable(short a_ItemDamage);
/** Blocks simply get placed */
virtual bool IsPlaceable(void);
@@ -102,7 +102,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/Items/ItemMilk.h b/src/Items/ItemMilk.h
index 62506a223..db7bc13be 100644
--- a/src/Items/ItemMilk.h
+++ b/src/Items/ItemMilk.h
@@ -11,9 +11,9 @@ public:
{
}
- virtual bool IsDrinkable(const cItem * a_Item) override
+ virtual bool IsDrinkable(short a_ItemDamage) override
{
- UNUSED(a_Item);
+ UNUSED(a_ItemDamage);
return true;
}
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 029bb52cd..c2441fa48 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -104,22 +104,17 @@ class cItemPotionHandler:
return base * tier_multi * ext_multi * splash_multi;
}
- bool IsDrinkable(short a_ItemDamage)
- {
- // Drinkable potion if 13th bit is set
- // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
- return a_ItemDamage & 8192;
- }
-
public:
cItemPotionHandler():
super(E_ITEM_POTIONS)
{
}
- virtual bool IsDrinkable(const cItem * a_Item) override
+ virtual bool IsDrinkable(short a_ItemDamage) override
{
- return IsDrinkable(a_Item->m_ItemDamage);
+ // Drinkable potion if 13th bit is set
+ // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return a_ItemDamage & 8192;
}
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
--
cgit v1.2.3
From 68011a004a83adc793f0df563cc924c5a2b7dddc Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 17:17:30 -0700
Subject: Removed long function wrapping
---
src/Entities/Pawn.cpp | 3 +--
src/Items/ItemPotion.h | 12 ++----------
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index a1f24138d..297b4afda 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -69,8 +69,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
}
m_EntityEffects[a_EffectType] = a_Effect;
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(),
- a_Effect.m_Ticks * a_Effect.GetDistanceModifier());
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks * a_Effect.GetDistanceModifier());
}
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index c2441fa48..40748d71c 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -123,12 +123,7 @@ public:
Vector3d Speed = a_Player->GetLookVector() * 7;
short potion_damage = a_Item.m_ItemDamage;
- cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed,
- GetEntityEffectType(potion_damage),
- cEntityEffect(GetEntityEffectDuration(potion_damage),
- GetEntityEffectIntensity(potion_damage),
- a_Player),
- GetPotionName(potion_damage));
+ cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player), GetPotionName(potion_damage));
if (Projectile == NULL)
{
return false;
@@ -152,10 +147,7 @@ public:
{
// Called when potion is a drinkable potion
short potion_damage = a_Item->m_ItemDamage;
- a_Player->AddEntityEffect(GetEntityEffectType(potion_damage),
- cEntityEffect(GetEntityEffectDuration(potion_damage),
- GetEntityEffectIntensity(potion_damage),
- a_Player));
+ a_Player->AddEntityEffect(GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player));
a_Player->GetInventory().RemoveOneEquippedItem();
a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
return true;
--
cgit v1.2.3
From 52abd90a28736ca07ad4b2df1259f3b54fd74c9d Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 18:14:34 -0700
Subject: Applies splash potion effects to mobs as well as players
---
src/Entities/SplashPotionEntity.cpp | 15 +++++++++------
src/Entities/SplashPotionEntity.h | 5 +++--
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 5dcea2385..e8bb0a420 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -1,7 +1,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "SplashPotionEntity.h"
-#include "Player.h"
+#include "Pawn.h"
@@ -44,8 +44,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_
void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
{
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
- m_World->ForEachPlayer(Callback);
- // TODO: Should be for each pawn
+ m_World->ForEachEntity(Callback);
m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName);
}
@@ -66,9 +65,9 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d
-bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player)
+bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
{
- double distance_splash = (a_Player->GetPosition() - m_HitPos).Length();
+ double distance_splash = (a_Entity->GetPosition() - m_HitPos).Length();
if (distance_splash < 20)
{
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
@@ -77,7 +76,11 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player)
if (reduction < 0) reduction = 0;
m_EntityEffect.SetDistanceModifier(reduction);
- a_Player->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
+
+ if (a_Entity->IsMob() || a_Entity->IsPlayer())
+ {
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
+ }
}
return false;
}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index b64b668a5..0f84e6387 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -7,6 +7,7 @@
#include "ProjectileEntity.h"
#include "EntityEffects.h"
#include "../World.h"
+#include "Entity.h"
@@ -42,12 +43,12 @@ protected:
int m_PotionName;
class cSplashPotionCallback :
- public cPlayerListCallback
+ public cEntityCallback
{
public:
cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect);
- virtual bool Item(cPlayer * a_Player) override;
+ virtual bool Item(cEntity *a_Entity) override;
private:
const Vector3d &m_HitPos;
--
cgit v1.2.3
From 2574573c883fd7b5d19d19547f34dbef6820b5ea Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 18:44:20 -0700
Subject: Monster: added IsUndead(), undead-specific entity effects
---
src/Entities/Pawn.cpp | 6 -----
src/Mobs/Monster.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/Mobs/Monster.h | 6 +++++
3 files changed, 71 insertions(+), 6 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 297b4afda..fee595e54 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -115,8 +115,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
{
// Base heal = 6, doubles for every increase in intensity
Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
-
- // TODO: Harms undead
return;
}
case cEntityEffect::effInstantDamage:
@@ -124,8 +122,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
// Base damage = 6, doubles for every increase in intensity
int damage = 6 * std::pow(2, a_Effect.GetIntensity());
TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0);
-
- // TODO: Heals undead
return;
}
case cEntityEffect::effStrength:
@@ -154,7 +150,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
counter = 0;
}
- // TODO: Doesn't effect undead
return;
}
case cEntityEffect::effPoison:
@@ -173,7 +168,6 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
counter = 0;
}
- // TODO: Doesn't effect undead or spiders
return;
}
case cEntityEffect::effFireResistance:
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 5843ca5a6..b8afbbc0c 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -435,6 +435,52 @@ void cMonster::HandleFalling()
+
+void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+{
+ switch (a_EffectType)
+ {
+ case cEntityEffect::effPoison:
+ {
+ // Default effect for non-undead mobs and non-spiders
+ if (!IsUndead() && GetMobType() != mtSpider) break;
+ return; // No effect
+ }
+ case cEntityEffect::effRegeneration:
+ {
+ // Default effect for non-undead mobs
+ if (!IsUndead() && GetMobType()) break;
+ return; // No effect
+ }
+ case cEntityEffect::effInstantDamage:
+ {
+ // Default effect for non-undead mobs
+ if (!IsUndead() && GetMobType()) break;
+
+ // Undead mobs are healed by instant damage
+ // Base heal = 6, doubles for every increase in intensity
+ Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
+ return;
+ }
+ case cEntityEffect::effInstantHealth:
+ {
+ // Default effect for non-undead mobs
+ if (!IsUndead() && GetMobType()) break;
+
+ // Undead mobs are damaged by instant health
+ // Base damage = 6, doubles for every increase in intensity
+ int damage = 6 * std::pow(2, a_Effect.GetIntensity());
+ TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0);
+ return;
+ }
+ }
+
+ super::HandleEntityEffects(a_EffectType, a_Effect);
+}
+
+
+
+
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
@@ -706,6 +752,25 @@ void cMonster::GetMonsterConfig(const AString & a_Name)
+bool cMonster::IsUndead(void)
+{
+ switch (GetMobType())
+ {
+ case mtZombie:
+ case mtZombiePigman:
+ case mtSkeleton:
+ case mtWither:
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
AString cMonster::MobTypeToString(cMonster::eType a_MobType)
{
// Mob types aren't sorted, so we need to search linearly:
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 7d7e90eb2..dbf95fbed 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -107,6 +107,9 @@ public:
/// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig(const AString & a_Name);
+ /** Returns whether this mob is undead (skeleton, zombie, etc.) */
+ bool IsUndead(void);
+
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);
@@ -178,6 +181,7 @@ protected:
/** Stores if mobile is currently moving towards the ultimate, final destination */
bool m_bMovingToDestination;
+
/** Finds the first non-air block position (not the highest, as cWorld::GetHeight does)
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
If current Y is solid, goes up to find first nonsolid block, and returns that */
@@ -220,6 +224,8 @@ protected:
int m_LastGroundHeight;
/* =========================== */
+
+ virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
float m_IdleInterval;
float m_DestroyTimer;
--
cgit v1.2.3
From 814cdca054bec5826b491f6d9d9867ce587d2def Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 8 Jun 2014 21:51:55 -0700
Subject: Added wither damage type, wither entity effect.
---
src/BlockID.cpp | 3 +++
src/BlockID.h | 2 ++
src/Entities/Entity.cpp | 1 +
src/Entities/Pawn.cpp | 16 +++++++++++++++-
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index bfe826f40..8edc51664 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -363,6 +363,7 @@ AString DamageTypeToString(eDamageType a_DamageType)
case dtLightning: return "dtLightning";
case dtOnFire: return "dtOnFire";
case dtPoisoning: return "dtPoisoning";
+ case dtWithering: return "dtWithering";
case dtPotionOfHarming: return "dtPotionOfHarming";
case dtRangedAttack: return "dtRangedAttack";
case dtStarving: return "dtStarving";
@@ -408,6 +409,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtCactusContact, "dtCactusContact"},
{ dtLavaContact, "dtLavaContact"},
{ dtPoisoning, "dtPoisoning"},
+ { dtWithering, "dtWithering"},
{ dtOnFire, "dtOnFire"},
{ dtFireContact, "dtFireContact"},
{ dtInVoid, "dtInVoid"},
@@ -433,6 +435,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString)
{ dtCactusContact, "dtCacti"},
{ dtLavaContact, "dtLava"},
{ dtPoisoning, "dtPoison"},
+ { dtWithering, "dtWither"},
{ dtOnFire, "dtBurning"},
{ dtFireContact, "dtInFire"},
{ dtAdmin, "dtPlugin"},
diff --git a/src/BlockID.h b/src/BlockID.h
index 272fd319d..e3567b6fc 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -811,6 +811,7 @@ enum eDamageType
dtCactusContact, // Contact with a cactus block
dtLavaContact, // Contact with a lava block
dtPoisoning, // Having the poison effect
+ dtWithering, // Having the wither effect
dtOnFire, // Being on fire
dtFireContact, // Standing inside a fire block
dtInVoid, // Falling into the Void (Y < 0)
@@ -837,6 +838,7 @@ enum eDamageType
dtCacti = dtCactusContact,
dtLava = dtLavaContact,
dtPoison = dtPoisoning,
+ dtWither = dtWithering,
dtBurning = dtOnFire,
dtInFire = dtFireContact,
dtPlugin = dtAdmin,
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index ba829bf6b..06833e1ba 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -432,6 +432,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
case dtStarving:
case dtInVoid:
case dtPoisoning:
+ case dtWithering:
case dtPotionOfHarming:
case dtFalling:
case dtLightning:
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index fee595e54..51ffc46b2 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -154,7 +154,7 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
}
case cEntityEffect::effPoison:
{
- // Poison frequency = 25 ticks, divided by potion level (Poison II = 25 ticks)
+ // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
static short counter = 0;
@@ -170,6 +170,20 @@ void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect
return;
}
+ case cEntityEffect::effWither:
+ {
+ // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
+ int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
+
+ static short counter = 0;
+ if (++counter >= frequency)
+ {
+ TakeDamage(dtWither, a_Effect.GetUser(), 1, 0);
+ counter = 0;
+ }
+ //TODO: " withered away>
+ return;
+ }
case cEntityEffect::effFireResistance:
{
// TODO: Implement me!
--
cgit v1.2.3
From 71b4c4949087860ab9962d6545a0ad2eb9c0ee5a Mon Sep 17 00:00:00 2001
From: archshift
Date: Wed, 11 Jun 2014 16:21:47 -0700
Subject: Cave spider now poisons its victim, added IsPawn function to Entity
---
src/Entities/Entity.h | 1 +
src/Entities/SplashPotionEntity.cpp | 2 +-
src/Mobs/AggressiveMonster.cpp | 10 ++++++----
src/Mobs/CaveSpider.cpp | 15 +++++++++++++++
src/Mobs/CaveSpider.h | 1 +
5 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index b8f1f4c1c..b5d5cc34c 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -158,6 +158,7 @@ public:
bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
bool IsPickup (void) const { return (m_EntityType == etPickup); }
bool IsMob (void) const { return (m_EntityType == etMonster); }
+ bool IsPawn (void) const { return (IsMob() || IsPlayer()); }
bool IsFallingBlock(void) const { return (m_EntityType == etFallingBlock); }
bool IsMinecart (void) const { return (m_EntityType == etMinecart); }
bool IsBoat (void) const { return (m_EntityType == etBoat); }
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index e8bb0a420..5574ea53c 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -77,7 +77,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
m_EntityEffect.SetDistanceModifier(reduction);
- if (a_Entity->IsMob() || a_Entity->IsPlayer())
+ if (a_Entity->IsPawn())
{
((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
}
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 85b122034..de881f4eb 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -95,12 +95,14 @@ void cAggressiveMonster::Attack(float a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
- if ((m_Target != NULL) && (m_AttackInterval > 3.0))
+ if ((m_Target == NULL) || (m_AttackInterval < 3.0))
{
- // Setting this higher gives us more wiggle room for attackrate
- m_AttackInterval = 0.0;
- m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
+ return;
}
+
+ // Setting this higher gives us more wiggle room for attackrate
+ m_AttackInterval = 0.0;
+ m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
}
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 1157b81f9..fe0f2ac73 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -27,6 +27,21 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
+void cCaveSpider::Attack(float a_Dt)
+{
+ super::Attack(a_Dt);
+
+ if (m_Target->IsPawn())
+ {
+ // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
+ ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, cEntityEffect(140, 0, this));
+ }
+}
+
+
+
+
+
void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
int LootingLevel = 0;
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index be9f174f9..3f8b2cece 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -17,6 +17,7 @@ public:
CLASS_PROTODEF(cCaveSpider);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Attack(float a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;
--
cgit v1.2.3
From 5b2b6e06150b6299d1e19374be092c0858b0e3a8 Mon Sep 17 00:00:00 2001
From: archshift
Date: Thu, 12 Jun 2014 19:50:02 -0700
Subject: Pawn: renamed HandleEntityEffects to HandleEntityEffect
Exported entity effect functions for ToLua and documented them in APIDesc.lua
---
MCServer/Plugins/APIDump/APIDesc.lua | 3 +++
src/Entities/Pawn.cpp | 4 ++--
src/Entities/Pawn.h | 4 +++-
src/Entities/Player.cpp | 4 ++--
src/Entities/Player.h | 2 +-
src/Items/ItemPotion.h | 2 +-
src/Mobs/Monster.cpp | 4 ++--
src/Mobs/Monster.h | 2 +-
8 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 19ca971e2..1dba08fe3 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1688,6 +1688,9 @@ a_Player:OpenWindow(Window);
TakeDamage = { Return = "" },
KilledBy = { Return = "" },
GetHealth = { Return = "number" },
+ AddEntityEffect = { Params = "EffectType, {{cEntityEffect}}", Return = "", Notes = "Applies an entity effect" },
+ RemoveEntityEffect = { Params = "EffectType", Return = "", Notes = "Removes a currently applied entity effect" },
+ ClearEntityEffects = { Return = "", Notes = "Removes all currently applied entity effects" },
},
Inherits = "cEntity",
}, -- cPawn
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 51ffc46b2..67b6fe4db 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -28,7 +28,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
cEntityEffect &effect_values = iter->second;
// Apply entity effect
- HandleEntityEffects(effect_type, effect_values);
+ HandleEntityEffect(effect_type, effect_values);
// Reduce the effect's duration
effect_values.m_Ticks--;
@@ -106,7 +106,7 @@ void cPawn::ClearEntityEffects()
-void cPawn::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
switch (a_EffectType)
{
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 47fb691f4..2ffdd9fbb 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -23,6 +23,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(cEntity * a_Killer) override;
+ // tolua_begin
/** Applies an entity effect
* @param a_EffectType The entity effect to apply
* @param a_Effect The parameters of the effect
@@ -36,6 +37,7 @@ public:
/** Removes all currently applied entity effects (used when drinking milk) */
void ClearEntityEffects();
+ // tolua_end
protected:
typedef std::map tEffectMap;
@@ -45,7 +47,7 @@ protected:
* @param a_EffectType The selected entity effect
* @param a_Effect The parameters of the selected entity effect
*/
- virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
+ virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 6bceab26f..5d8c3479b 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1867,7 +1867,7 @@ void cPlayer::TickBurning(cChunk & a_Chunk)
-void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+void cPlayer::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
switch (a_EffectType)
{
@@ -1897,7 +1897,7 @@ void cPlayer::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffe
}
}
- super::HandleEntityEffects(a_EffectType, a_Effect);
+ super::HandleEntityEffect(a_EffectType, a_Effect);
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 3aba3289d..a793d3c30 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -522,7 +522,7 @@ protected:
virtual void TickBurning(cChunk & a_Chunk) override;
/** Called each tick to handle entity effects*/
- virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
+ virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
/** Called in each tick to handle food-related processing */
void HandleFood(void);
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 40748d71c..2c5760e34 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -128,7 +128,7 @@ public:
{
return false;
}
- if (!Projectile->Initialize(*a_World))
+ if (!Projectile->Initialize(a_World))
{
delete Projectile;
return false;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index b8afbbc0c..4dfd81d88 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -436,7 +436,7 @@ void cMonster::HandleFalling()
-void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
switch (a_EffectType)
{
@@ -475,7 +475,7 @@ void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEff
}
}
- super::HandleEntityEffects(a_EffectType, a_Effect);
+ super::HandleEntityEffect(a_EffectType, a_Effect);
}
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index dbf95fbed..ca6cb0593 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -225,7 +225,7 @@ protected:
/* =========================== */
- virtual void HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
+ virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
float m_IdleInterval;
float m_DestroyTimer;
--
cgit v1.2.3
From 045ae2ef2c0d72b4902fa5151aad095823da9300 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 13 Jun 2014 09:49:42 +0200
Subject: Fixed MSVC compilation.
---
src/Entities/Pawn.cpp | 11 +++++++----
src/Items/ItemPotion.h | 14 +++++++-------
src/Mobs/Monster.cpp | 6 +++---
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 67b6fe4db..186e7df2a 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -114,14 +114,14 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
case cEntityEffect::effInstantHealth:
{
// Base heal = 6, doubles for every increase in intensity
- Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
+ Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()));
return;
}
case cEntityEffect::effInstantDamage:
{
// Base damage = 6, doubles for every increase in intensity
- int damage = 6 * std::pow(2, a_Effect.GetIntensity());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0);
+ int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
+ TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
return;
}
case cEntityEffect::effStrength:
@@ -132,7 +132,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
case cEntityEffect::effWeakness:
{
// Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage)
- //double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
+ // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
// TODO: Implement me!
// TODO: Weakened villager zombies can be turned back to villagers with the god apple
@@ -143,6 +143,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1));
+ // TODO: The counter needs to be specific to one cPawn, make it a member variable.
static short counter = 0;
if (++counter >= frequency)
{
@@ -157,6 +158,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
+ // TODO: The counter needs to be specific to one cPawn, make it a member variable.
static short counter = 0;
if (++counter >= frequency)
{
@@ -175,6 +177,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
+ // TODO: The counter needs to be specific to one cPawn, make it a member variable.
static short counter = 0;
if (++counter >= frequency)
{
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 2c5760e34..200c13cab 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -57,7 +57,7 @@ class cItemPotionHandler:
{
// Base duration in ticks
int base = 0;
- double tier_multi = 1, ext_multi = 1, splash_multi = 1;
+ double TierCoeff = 1, ExtCoeff = 1, SplashCoeff = 1;
switch (GetEntityEffectType(a_ItemDamage))
{
@@ -88,20 +88,20 @@ class cItemPotionHandler:
}
// If potion is level 2, half the duration. If not, stays the same
- tier_multi = GetEntityEffectIntensity(a_ItemDamage) > 0 ? 0.5 : 1;
+ TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1;
// If potion is extended, multiply duration by 8/3. If not, stays the same
// Extended potion if sixth bit is set
- ext_multi = a_ItemDamage & 64 ? (8.0/3.0) : 1;
+ ExtCoeff = (a_ItemDamage & 64) ? (8.0/3.0) : 1;
// If potion is splash potion, multiply duration by 3/4. If not, stays the same
- splash_multi = !IsDrinkable(a_ItemDamage) ? 0.75 : 1;
+ SplashCoeff = IsDrinkable(a_ItemDamage) ? 1 : 0.75;
// For reference: http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit
// http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
// http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
- return base * tier_multi * ext_multi * splash_multi;
+ return (int)(base * TierCoeff * ExtCoeff * SplashCoeff);
}
public:
@@ -114,7 +114,7 @@ public:
{
// Drinkable potion if 13th bit is set
// For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
- return a_ItemDamage & 8192;
+ return ((a_ItemDamage & 8192) != 0);
}
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
@@ -128,7 +128,7 @@ public:
{
return false;
}
- if (!Projectile->Initialize(a_World))
+ if (!Projectile->Initialize(*a_World))
{
delete Projectile;
return false;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 4dfd81d88..8a8c4f67a 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -459,7 +459,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe
// Undead mobs are healed by instant damage
// Base heal = 6, doubles for every increase in intensity
- Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
+ Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()));
return;
}
case cEntityEffect::effInstantHealth:
@@ -469,8 +469,8 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe
// Undead mobs are damaged by instant health
// Base damage = 6, doubles for every increase in intensity
- int damage = 6 * std::pow(2, a_Effect.GetIntensity());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0);
+ int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
+ TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
return;
}
}
--
cgit v1.2.3
From 22761bb6ad4b121ae3b2319a9a2541a6bb8a982c Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 13 Jun 2014 01:50:09 -0700
Subject: Entity Effect: Separates total duration and ticks of activity
Changed HandleEntityEffect to use cEntityEffect's ticks instead of a static counter
---
src/Entities/EntityEffects.cpp | 8 +++++---
src/Entities/EntityEffects.h | 13 ++++++++++---
src/Entities/Pawn.cpp | 24 ++++++++----------------
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp
index c74463bfa..e8448a6f1 100644
--- a/src/Entities/EntityEffects.cpp
+++ b/src/Entities/EntityEffects.cpp
@@ -8,6 +8,7 @@
cEntityEffect::cEntityEffect():
m_Ticks(0),
+ m_Duration(0),
m_Intensity(0),
m_User(NULL),
m_DistanceModifier(1)
@@ -19,11 +20,12 @@ cEntityEffect::cEntityEffect():
-cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier):
- m_Ticks(a_Ticks),
+cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier):
+ m_Ticks(0),
+ m_Duration(a_Duration),
m_Intensity(a_Intensity),
m_User(a_User),
m_DistanceModifier(a_DistanceModifier)
{
-}
\ No newline at end of file
+}
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 26d2c92e5..6b2532aae 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -35,9 +35,12 @@ public:
effSaturation = 23,
} ;
- /** The duration of the effect */
+ /** How many ticks this effect has been active for */
int m_Ticks;
+ /** Returns the duration of the effect */
+ int GetDuration() { return m_Duration; }
+
/** Returns how strong the effect will be applied */
short GetIntensity() { return m_Intensity; }
@@ -47,6 +50,7 @@ public:
/** Returns the distance modifier for affecting potency */
double GetDistanceModifier() { return m_DistanceModifier; }
+ void SetDuration(int a_Duration) { m_Duration = a_Duration; }
void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
void SetUser(cPawn *a_User) { m_User = a_User; }
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
@@ -58,14 +62,17 @@ public:
/**
* An entity effect
- * @param a_Ticks The duration of the effect
+ * @param a_Duration How long this effect will last
* @param a_Intensity How strong the effect will be applied
* @param a_User The pawn that used this entity effect
* @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1
*/
- cEntityEffect(int a_Ticks, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1);
+ cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1);
private:
+ /** How long this effect will last */
+ int m_Duration;
+
/** How strong the effect will be applied */
short m_Intensity;
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 186e7df2a..0273981f9 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -30,14 +30,14 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
// Apply entity effect
HandleEntityEffect(effect_type, effect_values);
- // Reduce the effect's duration
- effect_values.m_Ticks--;
+ // Increase the effect's tick counter
+ effect_values.m_Ticks++;
// Iterates (must be called before any possible erasure)
++iter;
// Remove effect if duration has elapsed
- if (effect_values.m_Ticks <= 0)
+ if (effect_values.GetDuration() - effect_values.m_Ticks <= 0)
{
RemoveEntityEffect(effect_type);
}
@@ -68,8 +68,9 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
return;
}
+ a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier());
m_EntityEffects[a_EffectType] = a_Effect;
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.m_Ticks * a_Effect.GetDistanceModifier());
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration());
}
@@ -143,12 +144,9 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1));
- // TODO: The counter needs to be specific to one cPawn, make it a member variable.
- static short counter = 0;
- if (++counter >= frequency)
+ if (a_Effect.m_Ticks % frequency == 0)
{
Heal(1);
- counter = 0;
}
return;
@@ -158,16 +156,13 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
- // TODO: The counter needs to be specific to one cPawn, make it a member variable.
- static short counter = 0;
- if (++counter >= frequency)
+ if (a_Effect.m_Ticks % frequency == 0)
{
// Cannot take poison damage when health is at 1
if (GetHealth() > 1)
{
TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0);
}
- counter = 0;
}
return;
@@ -177,12 +172,9 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
- // TODO: The counter needs to be specific to one cPawn, make it a member variable.
- static short counter = 0;
- if (++counter >= frequency)
+ if (a_Effect.m_Ticks % frequency == 0)
{
TakeDamage(dtWither, a_Effect.GetUser(), 1, 0);
- counter = 0;
}
//TODO: " withered away>
return;
--
cgit v1.2.3
From e289fe4dd7372a029ba85722e3ce99991e9d1d6b Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 13 Jun 2014 11:04:16 +0200
Subject: Changed the AddEntityEffect() params for easier calls.
---
src/Entities/EntityEffects.h | 27 ++++++++++++---------------
src/Entities/Pawn.cpp | 33 ++++++++++++++++-----------------
src/Entities/Pawn.h | 16 +++++++++-------
src/Entities/Player.cpp | 2 +-
src/Entities/SplashPotionEntity.cpp | 19 ++++++++++++-------
src/Items/ItemPotion.h | 3 +--
src/Mobs/CaveSpider.cpp | 2 +-
7 files changed, 52 insertions(+), 50 deletions(-)
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 6b2532aae..c0e8abd28 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -3,7 +3,8 @@
class cPawn;
// tolua_begin
-class cEntityEffect {
+class cEntityEffect
+{
public:
/** All types of entity effects (numbers correspond to IDs) */
@@ -52,25 +53,21 @@ public:
void SetDuration(int a_Duration) { m_Duration = a_Duration; }
void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
- void SetUser(cPawn *a_User) { m_User = a_User; }
+ void SetUser(cPawn * a_User) { m_User = a_User; }
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
- /**
- * An empty entity effect
- */
- cEntityEffect();
+ /** Creates an empty entity effect */
+ cEntityEffect(void);
- /**
- * An entity effect
- * @param a_Duration How long this effect will last
- * @param a_Intensity How strong the effect will be applied
- * @param a_User The pawn that used this entity effect
- * @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1
- */
- cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier = 1);
+ /** Creates an entity effect of the specified type
+ @param a_Duration How long this effect will last, in ticks
+ @param a_Intensity How strong the effect will be applied
+ @param a_User The pawn that used this entity effect
+ @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
+ cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1);
private:
- /** How long this effect will last */
+ /** How long this effect will last, in ticks */
int m_Duration;
/** How strong the effect will be applied */
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 0273981f9..ec829f6f8 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -8,9 +8,9 @@
-cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
- : cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
- , m_EntityEffects(tEffectMap())
+cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height):
+ super(a_EntityType, 0, 0, 0, a_Width, a_Height),
+ m_EntityEffects(tEffectMap())
{
}
@@ -24,22 +24,22 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
{
// Copies values to prevent pesky wrong accesses and erasures
- cEntityEffect::eType effect_type = iter->first;
- cEntityEffect &effect_values = iter->second;
+ cEntityEffect::eType EffectType = iter->first;
+ cEntityEffect & EffectValues = iter->second;
// Apply entity effect
- HandleEntityEffect(effect_type, effect_values);
+ HandleEntityEffect(EffectType, EffectValues);
- // Increase the effect's tick counter
- effect_values.m_Ticks++;
+ // Reduce the effect's duration
+ EffectValues.m_Ticks++;
// Iterates (must be called before any possible erasure)
++iter;
// Remove effect if duration has elapsed
- if (effect_values.GetDuration() - effect_values.m_Ticks <= 0)
+ if (EffectValues.GetDuration() - EffectValues.m_Ticks <= 0)
{
- RemoveEntityEffect(effect_type);
+ RemoveEntityEffect(EffectType);
}
// TODO: Check for discrepancies between client and server effect values
@@ -52,7 +52,7 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
-void cPawn::KilledBy(cEntity *a_Killer)
+void cPawn::KilledBy(cEntity * a_Killer)
{
ClearEntityEffects();
}
@@ -61,16 +61,15 @@ void cPawn::KilledBy(cEntity *a_Killer)
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier)
{
if (a_EffectType == cEntityEffect::effNoEffect)
{
return;
}
- a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier());
- m_EntityEffects[a_EffectType] = a_Effect;
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration());
+ m_EntityEffects[a_EffectType] = cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, this, a_DistanceModifier);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, (short)(a_EffectDurationTicks * a_DistanceModifier));
}
@@ -93,13 +92,13 @@ void cPawn::ClearEntityEffects()
for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
{
// Copy values to prevent pesky wrong erasures
- cEntityEffect::eType effect_type = iter->first;
+ cEntityEffect::eType EffectType = iter->first;
// Iterates (must be called before any possible erasure)
++iter;
// Remove effect
- RemoveEntityEffect(effect_type);
+ RemoveEntityEffect(EffectType);
}
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 2ffdd9fbb..399e02e64 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -24,19 +24,21 @@ public:
virtual void KilledBy(cEntity * a_Killer) override;
// tolua_begin
+
/** Applies an entity effect
- * @param a_EffectType The entity effect to apply
- * @param a_Effect The parameters of the effect
- */
- void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
+ @param a_EffectType The entity effect to apply
+ @param a_Effect The parameters of the effect
+ */
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
/** Removes a currently applied entity effect
- * @param a_EffectType The entity effect to remove
- */
+ @param a_EffectType The entity effect to remove
+ */
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
/** Removes all currently applied entity effects (used when drinking milk) */
- void ClearEntityEffects();
+ void ClearEntityEffects(void);
+
// tolua_end
protected:
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 5d8c3479b..f2ec81957 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- AddEntityEffect(cEntityEffect::effHunger, cEntityEffect(a_NumTicks, 0, NULL));
+ AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0);
}
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 5574ea53c..4035b4794 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -67,20 +67,25 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d
bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
{
- double distance_splash = (a_Entity->GetPosition() - m_HitPos).Length();
- if (distance_splash < 20)
+ double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
+ if (SplashDistance < 20)
{
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
// TODO: better equation
- double reduction = -0.25 * distance_splash + 1.0;
- if (reduction < 0) reduction = 0;
-
- m_EntityEffect.SetDistanceModifier(reduction);
+ double Reduction = -0.25 * SplashDistance + 1.0;
+ if (Reduction < 0)
+ {
+ Reduction = 0;
+ }
if (a_Entity->IsPawn())
{
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), Reduction);
}
}
return false;
}
+
+
+
+
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 200c13cab..70a926cad 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -146,8 +146,7 @@ public:
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
// Called when potion is a drinkable potion
- short potion_damage = a_Item->m_ItemDamage;
- a_Player->AddEntityEffect(GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player));
+ a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage));
a_Player->GetInventory().RemoveOneEquippedItem();
a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
return true;
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index fe0f2ac73..118a6e93b 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -34,7 +34,7 @@ void cCaveSpider::Attack(float a_Dt)
if (m_Target->IsPawn())
{
// TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
- ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, cEntityEffect(140, 0, this));
+ ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
}
}
--
cgit v1.2.3
From 9e8361976b6b0dc4c62ef48a4744ba1f59fe4346 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 13 Jun 2014 02:41:43 -0700
Subject: Entity Effects: Clarified user, added it to AddEntityEffect
Added second AddEntityEffect with a pass-by-value of the class.
---
src/Entities/EntityEffects.h | 6 +++---
src/Entities/Pawn.cpp | 16 +++++++++++++---
src/Entities/Pawn.h | 11 ++++++++++-
src/Entities/Player.cpp | 2 +-
src/Entities/SplashPotionEntity.cpp | 8 +++-----
src/Items/ItemPotion.h | 2 +-
src/Mobs/CaveSpider.cpp | 2 +-
7 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index c0e8abd28..2a4d0f723 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -45,7 +45,7 @@ public:
/** Returns how strong the effect will be applied */
short GetIntensity() { return m_Intensity; }
- /** Returns the pawn that used this entity effect */
+ /** Returns the pawn that produced this entity effect */
cPawn *GetUser() { return m_User; }
/** Returns the distance modifier for affecting potency */
@@ -62,7 +62,7 @@ public:
/** Creates an entity effect of the specified type
@param a_Duration How long this effect will last, in ticks
@param a_Intensity How strong the effect will be applied
- @param a_User The pawn that used this entity effect
+ @param a_User The pawn that produced this entity effect
@param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1);
@@ -73,7 +73,7 @@ private:
/** How strong the effect will be applied */
short m_Intensity;
- /** The pawn that used this entity effect */
+ /** The pawn that produced this entity effect (threw the potion, etc) */
cPawn *m_User;
/** The distance modifier for affecting potency */
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index ec829f6f8..2986799b7 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -61,15 +61,25 @@ void cPawn::KilledBy(cEntity * a_Killer)
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier)
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier)
+{
+ AddEntityEffect(a_EffectType, cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, a_User, a_DistanceModifier));
+}
+
+
+
+
+
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
if (a_EffectType == cEntityEffect::effNoEffect)
{
return;
}
- m_EntityEffects[a_EffectType] = cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, this, a_DistanceModifier);
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, (short)(a_EffectDurationTicks * a_DistanceModifier));
+ a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier());
+ m_EntityEffects[a_EffectType] = a_Effect;
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration());
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 399e02e64..3b83ec52f 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -25,11 +25,20 @@ public:
// tolua_begin
+ /** Applies an entity effect
+ @param a_EffectType The entity effect to apply
+ @param a_EffectDurationTicks The duration of the effect
+ @param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
+ @param a_User The pawn that produced the effect (e.g. threw the potion)
+ @param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions)
+ */
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1);
+
/** Applies an entity effect
@param a_EffectType The entity effect to apply
@param a_Effect The parameters of the effect
*/
- void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
/** Removes a currently applied entity effect
@param a_EffectType The entity effect to remove
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index f2ec81957..b7a315a40 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -570,7 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks)
{
- AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0);
+ AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, NULL);
}
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 4035b4794..714e4021d 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -68,7 +68,7 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d
bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
{
double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
- if (SplashDistance < 20)
+ if (SplashDistance < 20 && a_Entity->IsPawn())
{
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
// TODO: better equation
@@ -78,10 +78,8 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
Reduction = 0;
}
- if (a_Entity->IsPawn())
- {
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), Reduction);
- }
+ m_EntityEffect.SetDistanceModifier(Reduction);
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
}
return false;
}
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 70a926cad..853ed53a8 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -146,7 +146,7 @@ public:
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
// Called when potion is a drinkable potion
- a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage));
+ a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage), a_Player);
a_Player->GetInventory().RemoveOneEquippedItem();
a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
return true;
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 118a6e93b..34135714d 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -34,7 +34,7 @@ void cCaveSpider::Attack(float a_Dt)
if (m_Target->IsPawn())
{
// TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
- ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
+ ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0, this);
}
}
--
cgit v1.2.3
From fa1d85feca6beee9e07cf92f015a883a190c726a Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 13 Jun 2014 12:47:01 +0200
Subject: Added the OnEntityAddEffect hook.
---
src/Bindings/Plugin.h | 1 +
src/Bindings/PluginLua.cpp | 21 +++++++++++++++++++++
src/Bindings/PluginLua.h | 1 +
src/Bindings/PluginManager.cpp | 21 +++++++++++++++++++++
src/Bindings/PluginManager.h | 2 ++
src/Entities/Pawn.cpp | 9 +++++++++
src/Entities/Pawn.h | 2 ++
7 files changed, 57 insertions(+)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index c6461c861..2e02cba54 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -57,6 +57,7 @@ public:
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
+ virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) = 0;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 04639da60..09ffa6064 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -420,6 +420,26 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason
+bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
cCSLock Lock(m_CriticalSection);
@@ -1507,6 +1527,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
case cPluginManager::HOOK_CRAFTING_NO_RECIPE: return "OnCraftingNoRecipe";
case cPluginManager::HOOK_DISCONNECT: return "OnDisconnect";
case cPluginManager::HOOK_PLAYER_ANIMATION: return "OnPlayerAnimation";
+ case cPluginManager::HOOK_ENTITY_ADD_EFFECT: return "OnEntityAddEffect";
case cPluginManager::HOOK_EXECUTE_COMMAND: return "OnExecuteCommand";
case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake";
case cPluginManager::HOOK_KILLING: return "OnKilling";
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 598e031c0..d0dcfb011 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -80,6 +80,7 @@ public:
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
+ virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) override;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 9bcd8e3b7..d332980bd 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -448,6 +448,27 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
+bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier)
+{
+ HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT);
+ if (Plugins == m_Hooks.end())
+ {
+ return false;
+ }
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
FIND_HOOK(HOOK_EXECUTE_COMMAND);
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index be40bd2f7..4bd6b4837 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -73,6 +73,7 @@ public: // tolua_export
HOOK_CRAFTING_NO_RECIPE,
HOOK_DISCONNECT,
HOOK_PLAYER_ANIMATION,
+ HOOK_ENTITY_ADD_EFFECT,
HOOK_EXECUTE_COMMAND,
HOOK_EXPLODED,
HOOK_EXPLODING,
@@ -173,6 +174,7 @@ public: // tolua_export
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
+ bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier);
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 2986799b7..41a5b33ff 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -3,6 +3,7 @@
#include "Pawn.h"
#include "../World.h"
+#include "../Bindings/PluginManager.h"
@@ -72,6 +73,14 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
{
+ // Check if the plugins allow the addition:
+ if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Effect.GetDuration(), a_Effect.GetIntensity(), a_Effect.GetUser(), a_Effect.GetDistanceModifier()))
+ {
+ // A plugin disallows the addition, bail out.
+ return;
+ }
+
+ // No need to add empty effects:
if (a_EffectType == cEntityEffect::effNoEffect)
{
return;
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 3b83ec52f..c6be6f668 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -26,6 +26,7 @@ public:
// tolua_begin
/** Applies an entity effect
+ Checks with plugins if they allow the addition.
@param a_EffectType The entity effect to apply
@param a_EffectDurationTicks The duration of the effect
@param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
@@ -35,6 +36,7 @@ public:
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1);
/** Applies an entity effect
+ Checks with plugins if they allow the addition.
@param a_EffectType The entity effect to apply
@param a_Effect The parameters of the effect
*/
--
cgit v1.2.3
From a37d5410b4486dd95692076e3da0368a4ed23577 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 13 Jun 2014 12:50:54 +0200
Subject: APIDump: Added OnEntityAddEffect hook documentation.
---
.../Plugins/APIDump/Hooks/OnEntityAddEffect.lua | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua
diff --git a/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua
new file mode 100644
index 000000000..423a2200b
--- /dev/null
+++ b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua
@@ -0,0 +1,34 @@
+return
+{
+ HOOK_ENTITY_ADD_EFFECT =
+ {
+ CalledWhen = "An entity effect is about to get added to an entity.",
+ DefaultFnName = "OnEntityAddEffect", -- also used as pagename
+ Desc = [[
+ This hook is called whenever an entity effect is about to be added to an entity. The plugin may
+ disallow the addition by returning true.
+ Note that this hook only fires for adding the effect, but not for the actual effect application. See
+ also the {{OnEntityRemoveEffect|HOOK_ENTITY_REMOVE_EFFECT}} for notification about effects expiring /
+ removing, and {{OnEntityApplyEffect|HOOK_ENTITY_APPLY_EFFECT}} for the actual effect application to the
+ entity.
+ ]],
+ Params =
+ {
+ { Name = "Entity", Type = "{{cEntity}}", Notes = "The entity to which the effect is about to be added" },
+ { Name = "EffectType", Type = "number", Notes = "The type of the effect to be added. One of the effXXX constants." },
+ { Name = "EffectDuration", Type = "number", Notes = "The duration of the effect to be added, in ticks." },
+ { Name = "EffectIntensity", Type = "number", Notes = "The intensity (level) of the effect to be added. " },
+ { Name = "Originator", Type = "{{cEntity}}", Notes = "The entity who originated the effect (threw the potion, the cavespider that used poison bite, etc.) May be nil if there's no originator associated with the effect. " },
+ { Name = "DistanceModifier", Type = "number", Notes = "The modifier for the effect intensity, based on distance. Used mainly for splash potions." },
+ },
+ Returns = [[
+ If the plugin returns true, the effect will not be added and none of the remaining hook handlers will
+ be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally
+ the effect is added to the entity.
+ ]],
+ }, -- HOOK_EXECUTE_COMMAND
+}
+
+
+
+
--
cgit v1.2.3
From 68c30790db17b9d21b2fcda4c7edec679162c577 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 13 Jun 2014 10:59:59 -0700
Subject: Entity effects: changed User to Creator, removed pawn pass-by-value
---
src/Entities/EntityEffects.cpp | 6 +++---
src/Entities/EntityEffects.h | 10 +++++-----
src/Entities/Pawn.cpp | 25 ++++++++-----------------
src/Entities/Pawn.h | 11 ++---------
src/Entities/SplashPotionEntity.cpp | 2 +-
src/Mobs/Monster.cpp | 2 +-
6 files changed, 20 insertions(+), 36 deletions(-)
diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp
index e8448a6f1..a9edeee25 100644
--- a/src/Entities/EntityEffects.cpp
+++ b/src/Entities/EntityEffects.cpp
@@ -10,7 +10,7 @@ cEntityEffect::cEntityEffect():
m_Ticks(0),
m_Duration(0),
m_Intensity(0),
- m_User(NULL),
+ m_Creator(NULL),
m_DistanceModifier(1)
{
@@ -20,11 +20,11 @@ cEntityEffect::cEntityEffect():
-cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_User, double a_DistanceModifier):
+cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier):
m_Ticks(0),
m_Duration(a_Duration),
m_Intensity(a_Intensity),
- m_User(a_User),
+ m_Creator(a_Creator),
m_DistanceModifier(a_DistanceModifier)
{
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
index 2a4d0f723..9de3fcb86 100644
--- a/src/Entities/EntityEffects.h
+++ b/src/Entities/EntityEffects.h
@@ -46,14 +46,14 @@ public:
short GetIntensity() { return m_Intensity; }
/** Returns the pawn that produced this entity effect */
- cPawn *GetUser() { return m_User; }
+ cPawn *GetCreator() { return m_Creator; }
/** Returns the distance modifier for affecting potency */
double GetDistanceModifier() { return m_DistanceModifier; }
void SetDuration(int a_Duration) { m_Duration = a_Duration; }
void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
- void SetUser(cPawn * a_User) { m_User = a_User; }
+ void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; }
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
/** Creates an empty entity effect */
@@ -62,9 +62,9 @@ public:
/** Creates an entity effect of the specified type
@param a_Duration How long this effect will last, in ticks
@param a_Intensity How strong the effect will be applied
- @param a_User The pawn that produced this entity effect
+ @param a_Creator The pawn that produced this entity effect
@param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
- cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_User, double a_DistanceModifier = 1);
+ cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1);
private:
/** How long this effect will last, in ticks */
@@ -74,7 +74,7 @@ private:
short m_Intensity;
/** The pawn that produced this entity effect (threw the potion, etc) */
- cPawn *m_User;
+ cPawn *m_Creator;
/** The distance modifier for affecting potency */
double m_DistanceModifier;
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 41a5b33ff..6c70fd2a6 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -62,19 +62,10 @@ void cPawn::KilledBy(cEntity * a_Killer)
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier)
-{
- AddEntityEffect(a_EffectType, cEntityEffect(a_EffectDurationTicks, a_EffectIntensity, a_User, a_DistanceModifier));
-}
-
-
-
-
-
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier)
{
// Check if the plugins allow the addition:
- if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Effect.GetDuration(), a_Effect.GetIntensity(), a_Effect.GetUser(), a_Effect.GetDistanceModifier()))
+ if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Creator, a_DistanceModifier))
{
// A plugin disallows the addition, bail out.
return;
@@ -86,9 +77,9 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_E
return;
}
- a_Effect.SetDuration(a_Effect.GetDuration() * a_Effect.GetDistanceModifier());
- m_EntityEffects[a_EffectType] = a_Effect;
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_Effect.GetIntensity(), a_Effect.GetDuration());
+ int EffectDuration = (int)(a_EffectDurationTicks * a_DistanceModifier);
+ m_EntityEffects[a_EffectType] = cEntityEffect(EffectDuration, a_EffectIntensity, a_Creator, a_DistanceModifier);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, EffectDuration);
}
@@ -140,7 +131,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
{
// Base damage = 6, doubles for every increase in intensity
int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
+ TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0);
return;
}
case cEntityEffect::effStrength:
@@ -179,7 +170,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
// Cannot take poison damage when health is at 1
if (GetHealth() > 1)
{
- TakeDamage(dtPoisoning, a_Effect.GetUser(), 1, 0);
+ TakeDamage(dtPoisoning, a_Effect.GetCreator(), 1, 0);
}
}
@@ -192,7 +183,7 @@ void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect
if (a_Effect.m_Ticks % frequency == 0)
{
- TakeDamage(dtWither, a_Effect.GetUser(), 1, 0);
+ TakeDamage(dtWither, a_Effect.GetCreator(), 1, 0);
}
//TODO: " withered away>
return;
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index c6be6f668..9f7771d79 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -30,17 +30,10 @@ public:
@param a_EffectType The entity effect to apply
@param a_EffectDurationTicks The duration of the effect
@param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
- @param a_User The pawn that produced the effect (e.g. threw the potion)
+ @param a_Creator The pawn that produced the effect (e.g. threw the potion)
@param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions)
*/
- void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_User, double a_DistanceModifier = 1);
-
- /** Applies an entity effect
- Checks with plugins if they allow the addition.
- @param a_EffectType The entity effect to apply
- @param a_Effect The parameters of the effect
- */
- void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier = 1);
/** Removes a currently applied entity effect
@param a_EffectType The entity effect to remove
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 714e4021d..2a1e9d981 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
}
m_EntityEffect.SetDistanceModifier(Reduction);
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect);
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction);
}
return false;
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 8a8c4f67a..4c59960f6 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -470,7 +470,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe
// Undead mobs are damaged by instant health
// Base damage = 6, doubles for every increase in intensity
int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
- TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0);
+ TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0);
return;
}
}
--
cgit v1.2.3
From e0a9f37d909e9d82ccac88dae910ce21a7fdba6f Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Wed, 18 Jun 2014 12:13:01 +0200
Subject: (Force)ExecuteCommand returns the CommandResult enums Exported and
documented the CommandResult enums
---
MCServer/Plugins/APIDump/APIDesc.lua | 19 +++++++++++++++++--
src/Bindings/PluginManager.cpp | 8 ++++----
src/Bindings/PluginManager.h | 8 ++++----
3 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 19ca971e2..fe38d94c7 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1872,9 +1872,9 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." },
DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." },
- ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." },
+ ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." },
FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" },
- ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
+ ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature: function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature: function (Command, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
Get = { Params = "", Return = "cPluginManager", Notes = "(STATIC) Returns the single instance of the plugin manager" },
@@ -1890,8 +1890,23 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
LogStackTrace = { Params = "", Return = "", Notes = "(STATIC) Logs a current stack trace of the Lua engine to the server console log. Same format as is used when the plugin fails." },
ReloadPlugins = { Params = "", Return = "", Notes = "Reloads all active plugins" },
},
+ ConstantGroups=
+ {
+ CommandResult =
+ {
+ Include = "^cr.*",
+ TextBefore = [[
+ Results that the (Force)ExecuteCommand return. This gives information if the command is executed or not and the reason.
+ ]],
+ },
+ },
Constants =
{
+ crBlocked = { Notes = "When a plugin stopped the command using the OnExecuteCommand hook" },
+ crError = { Notes = "When the command handler for the given command results in an error" },
+ crExecuted = { Notes = "When the command is successfully executed." },
+ crNoPermission = { Notes = "When the player doesn't have permission to execute the given command." },
+ crUnknownCommand = { Notes = "When the given command doesn't exist." },
HOOK_BLOCK_SPREAD = { Notes = "Called when a block spreads based on world conditions" },
HOOK_BLOCK_TO_PICKUPS = { Notes = "Called when a block has been dug and is being converted to pickups. The server has provided the default pickups and the plugins may modify them." },
HOOK_CHAT = { Notes = "Called when a client sends a chat message that is not a command. The plugin may modify the chat message" },
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index c317ae362..2cd514211 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1553,18 +1553,18 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command)
-bool cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
+cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
- return (HandleCommand(a_Player, a_Command, true) == crExecuted);
+ return HandleCommand(a_Player, a_Command, true);
}
-bool cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
+cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
{
- return (HandleCommand(a_Player, a_Command, false) == crExecuted);
+ return HandleCommand(a_Player, a_Command, false);
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 96b7a979b..e2bd9cd94 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -57,7 +57,8 @@ public: // tolua_export
// Called each tick
virtual void Tick(float a_Dt);
-
+
+ // tolua_begin
enum CommandResult
{
crExecuted,
@@ -67,7 +68,6 @@ public: // tolua_export
crNoPermission,
} ;
- // tolua_begin
enum PluginHook
{
HOOK_BLOCK_SPREAD,
@@ -254,10 +254,10 @@ public: // tolua_export
AString GetCommandPermission(const AString & a_Command); // tolua_export
/** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns true if executed. */
- bool ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
+ CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) */
- bool ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
+ CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Removes all console command bindings that the specified plugin has made */
void RemovePluginConsoleCommands(cPlugin * a_Plugin);
--
cgit v1.2.3
From f5529e544cf8350daf8a20bb8d997f85ee2824f7 Mon Sep 17 00:00:00 2001
From: archshift
Date: Mon, 16 Jun 2014 20:22:17 -0700
Subject: EntityEffects.x -> EntityEffect.x, Object-Oriented effects
Changed effect map to take a pointer of the effect as a result.
---
src/Bindings/AllToLua.pkg | 2 +-
src/CMakeLists.txt | 2 +-
src/Entities/EntityEffect.cpp | 291 ++++++++++++++++++++++++
src/Entities/EntityEffect.h | 438 ++++++++++++++++++++++++++++++++++++
src/Entities/EntityEffects.cpp | 31 ---
src/Entities/EntityEffects.h | 82 -------
src/Entities/Pawn.cpp | 119 +---------
src/Entities/Pawn.h | 10 +-
src/Entities/Player.cpp | 37 ---
src/Entities/Player.h | 3 -
src/Entities/SplashPotionEntity.cpp | 2 +-
src/Entities/SplashPotionEntity.h | 2 +-
src/Items/ItemPotion.h | 2 +-
src/Mobs/Monster.cpp | 45 ----
src/Mobs/Monster.h | 2 -
15 files changed, 748 insertions(+), 320 deletions(-)
create mode 100644 src/Entities/EntityEffect.cpp
create mode 100644 src/Entities/EntityEffect.h
delete mode 100644 src/Entities/EntityEffects.cpp
delete mode 100644 src/Entities/EntityEffects.h
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 4a6eb7535..1e5dfd2fe 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/TNTEntity.h"
-$cfile "../Entities/EntityEffects.h"
+$cfile "../Entities/EntityEffect.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3d5a0e396..678db3fb4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,7 +42,7 @@ set(BINDING_DEPENDECIES
Cuboid.h
Defines.h
Enchantments.h
- Entities/EntityEffects.h
+ Entities/EntityEffect.h
Entities/Entity.h
Entities/Floater.h
Entities/Pawn.h
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
new file mode 100644
index 000000000..9881785cb
--- /dev/null
+++ b/src/Entities/EntityEffect.cpp
@@ -0,0 +1,291 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "EntityEffect.h"
+#include "../Mobs/Monster.h"
+#include "Player.h"
+
+
+
+
+cEntityEffect::cEntityEffect():
+ m_Ticks(0),
+ m_Duration(0),
+ m_Intensity(0),
+ m_Creator(NULL),
+ m_DistanceModifier(1)
+{
+
+}
+
+
+
+
+
+cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier):
+ m_Ticks(0),
+ m_Duration(a_Duration),
+ m_Intensity(a_Intensity),
+ m_Creator(a_Creator),
+ m_DistanceModifier(a_DistanceModifier)
+{
+
+}
+
+
+
+
+
+cEntityEffect::~cEntityEffect()
+{
+
+}
+
+
+
+
+
+cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier)
+{
+ switch (a_EffectType)
+ {
+ case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+
+ case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ }
+
+ ASSERT(!"Unhandled entity effect type!");
+}
+
+
+
+
+
+void cEntityEffect::OnTick(cPawn & a_Target)
+{
+ // Reduce the effect's duration
+ ++m_Ticks;
+}
+
+
+
+
+
+void cEntityEffect::OnActivate(cPawn & a_Target)
+{
+}
+
+
+
+
+
+void cEntityEffect::OnDeactivate(cPawn & a_Target)
+{
+}
+
+
+
+
+
+/************************************************************************
+ **** Instant Health
+ ************************************************************************/
+void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
+{
+ // Base amount = 6, doubles for every increase in intensity
+ int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier);
+
+ if (a_Target.IsMob())
+ {
+ if (((cMonster &) a_Target).IsUndead())
+ {
+ a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0);
+ return;
+ }
+ }
+ a_Target.Heal(amount);
+}
+
+
+
+
+
+/************************************************************************
+ **** Instant Damage
+ ************************************************************************/
+void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
+{
+ // Base amount = 6, doubles for every increase in intensity
+ int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier);
+
+ if (a_Target.IsMob())
+ {
+ if (((cMonster &) a_Target).IsUndead())
+ {
+ a_Target.Heal(amount);
+ return;
+ }
+ }
+ a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0);
+}
+
+
+
+
+
+/************************************************************************
+ **** Regeneration
+ ************************************************************************/
+void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ if (a_Target.IsMob())
+ {
+ if (((cMonster &) a_Target).IsUndead())
+ {
+ return;
+ }
+ }
+
+ // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
+ int frequency = (int) std::floor(50.0 / (double)(m_Intensity + 1));
+
+ if (m_Ticks % frequency != 0)
+ {
+ return;
+ }
+
+ a_Target.Heal(1);
+}
+
+
+
+
+
+/************************************************************************
+ **** Hunger
+ ************************************************************************/
+void cEntityEffectHunger::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ if (a_Target.IsPlayer())
+ {
+ cPlayer & Target = (cPlayer &) a_Target;
+ Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick
+ }
+}
+
+
+
+
+
+/************************************************************************
+ **** Weakness
+ ************************************************************************/
+void cEntityEffectWeakness::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage)
+ // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
+
+ // TODO: Implement me!
+ // TODO: Weakened villager zombies can be turned back to villagers with the god apple
+}
+
+
+
+
+
+/************************************************************************
+ **** Poison
+ ************************************************************************/
+void cEntityEffectPoison::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ if (a_Target.IsMob())
+ {
+ cMonster & Target = (cMonster &) a_Target;
+
+ // Doesn't effect undead mobs, spiders
+ if (Target.IsUndead()
+ || Target.GetMobType() == cMonster::mtSpider
+ || Target.GetMobType() == cMonster::mtCaveSpider)
+ {
+ return;
+ }
+ }
+
+ // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
+ int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
+
+ if (m_Ticks % frequency == 0)
+ {
+ // Cannot take poison damage when health is at 1
+ if (a_Target.GetHealth() > 1)
+ {
+ a_Target.TakeDamage(dtPoisoning, m_Creator, 1, 0);
+ }
+ }
+}
+
+
+
+
+
+/************************************************************************
+ **** Wither
+ ************************************************************************/
+void cEntityEffectWither::OnTick(cPawn & a_Target)
+{
+ super::OnTick(a_Target);
+
+ // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
+ int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
+
+ if (m_Ticks % frequency == 0)
+ {
+ a_Target.TakeDamage(dtWither, m_Creator, 1, 0);
+ }
+ //TODO: " withered away>
+}
+
+
+
+
+
+/************************************************************************
+ **** Saturation
+ ************************************************************************/
+void cEntityEffectSaturation::OnTick(cPawn & a_Target)
+{
+ if (a_Target.IsPlayer())
+ {
+ cPlayer & Target = (cPlayer &) a_Target;
+ Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
+ }
+}
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
new file mode 100644
index 000000000..ae7958e11
--- /dev/null
+++ b/src/Entities/EntityEffect.h
@@ -0,0 +1,438 @@
+#pragma once
+
+class cPawn;
+
+// tolua_begin
+class cEntityEffect
+{
+public:
+
+ /** All types of entity effects (numbers correspond to IDs) */
+ enum eType
+ {
+ effNoEffect = 0,
+ effSpeed = 1,
+ effSlowness = 2,
+ effHaste = 3,
+ effMiningFatigue = 4,
+ effStrength = 5,
+ effInstantHealth = 6,
+ effInstantDamage = 7,
+ effJumpBoost = 8,
+ effNausea = 9,
+ effRegeneration = 10,
+ effResistance = 11,
+ effFireResistance = 12,
+ effWaterBreathing = 13,
+ effInvisibility = 14,
+ effBlindness = 15,
+ effNightVision = 16,
+ effHunger = 17,
+ effWeakness = 18,
+ effPoison = 19,
+ effWither = 20,
+ effHealthBoost = 21,
+ effAbsorption = 22,
+ effSaturation = 23,
+ } ;
+
+ /** Creates an empty entity effect */
+ cEntityEffect(void);
+
+ /** Creates an entity effect of the specified type
+ @param a_Duration How long this effect will last, in ticks
+ @param a_Intensity How strong the effect will be applied
+ @param a_Creator The pawn that produced this entity effect
+ @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
+ cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1);
+
+ virtual ~cEntityEffect(void);
+
+ /** Creates a pointer to the proper entity effect from the effect type
+ @warning This function creates raw pointers that must be manually managed.
+ @param a_EffectType The effect type to create the effect from
+ @param a_Duration How long this effect will last, in ticks
+ @param a_Intensity How strong the effect will be applied
+ @param a_Creator The pawn that produced this entity effect
+ @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
+ static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier);
+
+ /** Returns how many ticks this effect has been active for */
+ int GetTicks() { return m_Ticks; }
+ /** Returns the duration of the effect */
+ int GetDuration() { return m_Duration; }
+ /** Returns how strong the effect will be applied */
+ short GetIntensity() { return m_Intensity; }
+ /** Returns the pawn that produced this entity effect */
+ cPawn *GetCreator() { return m_Creator; }
+ /** Returns the distance modifier for affecting potency */
+ double GetDistanceModifier() { return m_DistanceModifier; }
+
+ void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; }
+ void SetDuration(int a_Duration) { m_Duration = a_Duration; }
+ void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
+ void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; }
+ void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
+
+ virtual void OnTick(cPawn & a_Target);
+ virtual void OnActivate(cPawn & a_Target);
+ virtual void OnDeactivate(cPawn & a_Target);
+
+protected:
+ /** How many ticks this effect has been active for */
+ int m_Ticks;
+
+ /** How long this effect will last, in ticks */
+ int m_Duration;
+
+ /** How strong the effect will be applied */
+ short m_Intensity;
+
+ /** The pawn that produced this entity effect (threw the potion, etc) */
+ cPawn *m_Creator;
+
+ /** The distance modifier for affecting potency */
+ double m_DistanceModifier;
+};
+
+/************************************************************************
+ **** Speed
+ ************************************************************************/
+class cEntityEffectSpeed:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectSpeed(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Slowness
+ ************************************************************************/
+class cEntityEffectSlowness:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectSlowness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Haste
+ ************************************************************************/
+class cEntityEffectHaste:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectHaste(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Mining Fatigue
+ ************************************************************************/
+class cEntityEffectMiningFatigue:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Strength
+ ************************************************************************/
+class cEntityEffectStrength:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectStrength(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Instant Health
+ ************************************************************************/
+class cEntityEffectInstantHealth:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectInstantHealth(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnActivate(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Instant Damage
+ ************************************************************************/
+class cEntityEffectInstantDamage:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectInstantDamage(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnActivate(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Jump Boost
+ ************************************************************************/
+class cEntityEffectJumpBoost:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectJumpBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Nausea
+ ************************************************************************/
+class cEntityEffectNausea:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectNausea(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Regeneration
+ ************************************************************************/
+class cEntityEffectRegeneration:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectRegeneration(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Resistance
+ ************************************************************************/
+class cEntityEffectResistance:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Fire Resistance
+ ************************************************************************/
+class cEntityEffectFireResistance:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectFireResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Water Breathing
+ ************************************************************************/
+class cEntityEffectWaterBreathing:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Invisibility
+ ************************************************************************/
+class cEntityEffectInvisibility:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectInvisibility(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Blindness
+ ************************************************************************/
+class cEntityEffectBlindness:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectBlindness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Night Vision
+ ************************************************************************/
+class cEntityEffectNightVision:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectNightVision(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Hunger
+ ************************************************************************/
+class cEntityEffectHunger:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectHunger(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Weakness
+ ************************************************************************/
+class cEntityEffectWeakness:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectWeakness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Poison
+ ************************************************************************/
+class cEntityEffectPoison:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectPoison(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Wither
+ ************************************************************************/
+class cEntityEffectWither:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectWither(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+/************************************************************************
+ **** Health Boost
+ ************************************************************************/
+class cEntityEffectHealthBoost:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectHealthBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Absorption
+ ************************************************************************/
+class cEntityEffectAbsorption:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectAbsorption(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+};
+
+/************************************************************************
+ **** Saturation
+ ************************************************************************/
+class cEntityEffectSaturation:
+ public cEntityEffect
+{
+ typedef cEntityEffect super;
+public:
+ cEntityEffectSaturation(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ {
+ }
+
+ virtual void OnTick(cPawn & a_Target) override;
+};
+
+
+
+// tolua_end
diff --git a/src/Entities/EntityEffects.cpp b/src/Entities/EntityEffects.cpp
deleted file mode 100644
index a9edeee25..000000000
--- a/src/Entities/EntityEffects.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "EntityEffects.h"
-#include "Pawn.h"
-
-
-
-
-cEntityEffect::cEntityEffect():
- m_Ticks(0),
- m_Duration(0),
- m_Intensity(0),
- m_Creator(NULL),
- m_DistanceModifier(1)
-{
-
-}
-
-
-
-
-
-cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier):
- m_Ticks(0),
- m_Duration(a_Duration),
- m_Intensity(a_Intensity),
- m_Creator(a_Creator),
- m_DistanceModifier(a_DistanceModifier)
-{
-
-}
diff --git a/src/Entities/EntityEffects.h b/src/Entities/EntityEffects.h
deleted file mode 100644
index 9de3fcb86..000000000
--- a/src/Entities/EntityEffects.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#pragma once
-
-class cPawn;
-
-// tolua_begin
-class cEntityEffect
-{
-public:
-
- /** All types of entity effects (numbers correspond to IDs) */
- enum eType
- {
- effNoEffect = 0,
- effSpeed = 1,
- effSlowness = 2,
- effHaste = 3,
- effMiningFatigue = 4,
- effStrength = 5,
- effInstantHealth = 6,
- effInstantDamage = 7,
- effJumpBoost = 8,
- effNausea = 9,
- effRegeneration = 10,
- effResistance = 11,
- effFireResistance = 12,
- effWaterBreathing = 13,
- effInvisibility = 14,
- effBlindness = 15,
- effNightVision = 16,
- effHunger = 17,
- effWeakness = 18,
- effPoison = 19,
- effWither = 20,
- effHealthBoost = 21,
- effAbsorption = 22,
- effSaturation = 23,
- } ;
-
- /** How many ticks this effect has been active for */
- int m_Ticks;
-
- /** Returns the duration of the effect */
- int GetDuration() { return m_Duration; }
-
- /** Returns how strong the effect will be applied */
- short GetIntensity() { return m_Intensity; }
-
- /** Returns the pawn that produced this entity effect */
- cPawn *GetCreator() { return m_Creator; }
-
- /** Returns the distance modifier for affecting potency */
- double GetDistanceModifier() { return m_DistanceModifier; }
-
- void SetDuration(int a_Duration) { m_Duration = a_Duration; }
- void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
- void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; }
- void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
-
- /** Creates an empty entity effect */
- cEntityEffect(void);
-
- /** Creates an entity effect of the specified type
- @param a_Duration How long this effect will last, in ticks
- @param a_Intensity How strong the effect will be applied
- @param a_Creator The pawn that produced this entity effect
- @param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
- cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1);
-
-private:
- /** How long this effect will last, in ticks */
- int m_Duration;
-
- /** How strong the effect will be applied */
- short m_Intensity;
-
- /** The pawn that produced this entity effect (threw the potion, etc) */
- cPawn *m_Creator;
-
- /** The distance modifier for affecting potency */
- double m_DistanceModifier;
-};
-// tolua_end
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 6c70fd2a6..62f71e20f 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -26,19 +26,15 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
{
// Copies values to prevent pesky wrong accesses and erasures
cEntityEffect::eType EffectType = iter->first;
- cEntityEffect & EffectValues = iter->second;
+ cEntityEffect * Effect = iter->second;
- // Apply entity effect
- HandleEntityEffect(EffectType, EffectValues);
-
- // Reduce the effect's duration
- EffectValues.m_Ticks++;
+ Effect->OnTick(*this);
// Iterates (must be called before any possible erasure)
++iter;
// Remove effect if duration has elapsed
- if (EffectValues.GetDuration() - EffectValues.m_Ticks <= 0)
+ if (Effect->GetDuration() - Effect->GetTicks() <= 0)
{
RemoveEntityEffect(EffectType);
}
@@ -62,10 +58,10 @@ void cPawn::KilledBy(cEntity * a_Killer)
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier)
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier)
{
// Check if the plugins allow the addition:
- if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Creator, a_DistanceModifier))
+ if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier))
{
// A plugin disallows the addition, bail out.
return;
@@ -76,10 +72,11 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat
{
return;
}
+ a_Duration = (int)(a_Duration * a_DistanceModifier);
- int EffectDuration = (int)(a_EffectDurationTicks * a_DistanceModifier);
- m_EntityEffects[a_EffectType] = cEntityEffect(EffectDuration, a_EffectIntensity, a_Creator, a_DistanceModifier);
- m_World->BroadcastEntityEffect(*this, a_EffectType, a_EffectIntensity, EffectDuration);
+ m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, a_Duration);
+ m_EntityEffects[a_EffectType]->OnActivate(*this);
}
@@ -88,8 +85,10 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurat
void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
{
- m_EntityEffects.erase(a_EffectType);
m_World->BroadcastRemoveEntityEffect(*this, a_EffectType);
+ m_EntityEffects[a_EffectType]->OnDeactivate(*this);
+ delete m_EntityEffects[a_EffectType];
+ m_EntityEffects.erase(a_EffectType);
}
@@ -111,97 +110,3 @@ void cPawn::ClearEntityEffects()
RemoveEntityEffect(EffectType);
}
}
-
-
-
-
-
-void cPawn::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
-{
- switch (a_EffectType)
- {
- // Default effect behaviors
- case cEntityEffect::effInstantHealth:
- {
- // Base heal = 6, doubles for every increase in intensity
- Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()));
- return;
- }
- case cEntityEffect::effInstantDamage:
- {
- // Base damage = 6, doubles for every increase in intensity
- int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
- TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0);
- return;
- }
- case cEntityEffect::effStrength:
- {
- // TODO: Implement me!
- return;
- }
- case cEntityEffect::effWeakness:
- {
- // Damage reduction = 0.5 damage, multiplied by potion level (Weakness II = 1 damage)
- // double dmg_reduc = 0.5 * (a_Effect.GetIntensity() + 1);
-
- // TODO: Implement me!
- // TODO: Weakened villager zombies can be turned back to villagers with the god apple
- return;
- }
- case cEntityEffect::effRegeneration:
- {
- // Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
- int frequency = std::floor(50.0 / (double)(a_Effect.GetIntensity() + 1));
-
- if (a_Effect.m_Ticks % frequency == 0)
- {
- Heal(1);
- }
-
- return;
- }
- case cEntityEffect::effPoison:
- {
- // Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
- int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
-
- if (a_Effect.m_Ticks % frequency == 0)
- {
- // Cannot take poison damage when health is at 1
- if (GetHealth() > 1)
- {
- TakeDamage(dtPoisoning, a_Effect.GetCreator(), 1, 0);
- }
- }
-
- return;
- }
- case cEntityEffect::effWither:
- {
- // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
- int frequency = std::floor(25.0 / (double)(a_Effect.GetIntensity() + 1));
-
- if (a_Effect.m_Ticks % frequency == 0)
- {
- TakeDamage(dtWither, a_Effect.GetCreator(), 1, 0);
- }
- //TODO: " withered away>
- return;
- }
- case cEntityEffect::effFireResistance:
- {
- // TODO: Implement me!
- return;
- }
- case cEntityEffect::effSpeed:
- {
- // TODO: Implement me!
- return;
- }
- case cEntityEffect::effSlowness:
- {
- // TODO: Implement me!
- return;
- }
- }
-}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 9f7771d79..307e5db3d 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -2,7 +2,7 @@
#pragma once
#include "Entity.h"
-#include "EntityEffects.h"
+#include "EntityEffect.h"
@@ -46,14 +46,8 @@ public:
// tolua_end
protected:
- typedef std::map tEffectMap;
+ typedef std::map tEffectMap;
tEffectMap m_EntityEffects;
-
- /** Applies entity effect effects
- * @param a_EffectType The selected entity effect
- * @param a_Effect The parameters of the selected entity effect
- */
- virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index b7a315a40..77ab6d309 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1867,43 +1867,6 @@ void cPlayer::TickBurning(cChunk & a_Chunk)
-void cPlayer::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
-{
- switch (a_EffectType)
- {
- // Effects whose behaviors are overridden
- case cEntityEffect::effMiningFatigue:
- {
- // TODO: Implement me!
- return;
- }
- case cEntityEffect::effHunger:
- {
- m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
- return;
- }
- case cEntityEffect::effSaturation:
- {
- // Increase saturation 1 per tick, adds 1 for every increase in level
- m_FoodSaturationLevel += (1 + a_Effect.GetIntensity());
- return;
- }
-
- // Client-side-only effects
- case cEntityEffect::effNausea:
- case cEntityEffect::effNightVision:
- {
- return;
- }
- }
-
- super::HandleEntityEffect(a_EffectType, a_Effect);
-}
-
-
-
-
-
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index a793d3c30..e80b82901 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -521,9 +521,6 @@ protected:
/** Stops players from burning in creative mode */
virtual void TickBurning(cChunk & a_Chunk) override;
- /** Called each tick to handle entity effects*/
- virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
-
/** Called in each tick to handle food-related processing */
void HandleFood(void);
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 2a1e9d981..3d2ef279f 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
}
m_EntityEffect.SetDistanceModifier(Reduction);
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.m_Ticks, m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction);
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction);
}
return false;
}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 0f84e6387..548ba3a3e 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -5,7 +5,7 @@
#pragma once
#include "ProjectileEntity.h"
-#include "EntityEffects.h"
+#include "EntityEffect.h"
#include "../World.h"
#include "Entity.h"
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 853ed53a8..43b9f280d 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -1,7 +1,7 @@
#pragma once
-#include "../Entities/EntityEffects.h"
+#include "../Entities/EntityEffect.h"
#include "../Entities/SplashPotionEntity.h"
class cItemPotionHandler:
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 4c59960f6..a51315ecf 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -436,51 +436,6 @@ void cMonster::HandleFalling()
-void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
-{
- switch (a_EffectType)
- {
- case cEntityEffect::effPoison:
- {
- // Default effect for non-undead mobs and non-spiders
- if (!IsUndead() && GetMobType() != mtSpider) break;
- return; // No effect
- }
- case cEntityEffect::effRegeneration:
- {
- // Default effect for non-undead mobs
- if (!IsUndead() && GetMobType()) break;
- return; // No effect
- }
- case cEntityEffect::effInstantDamage:
- {
- // Default effect for non-undead mobs
- if (!IsUndead() && GetMobType()) break;
-
- // Undead mobs are healed by instant damage
- // Base heal = 6, doubles for every increase in intensity
- Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()));
- return;
- }
- case cEntityEffect::effInstantHealth:
- {
- // Default effect for non-undead mobs
- if (!IsUndead() && GetMobType()) break;
-
- // Undead mobs are damaged by instant health
- // Base damage = 6, doubles for every increase in intensity
- int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
- TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0);
- return;
- }
- }
-
- super::HandleEntityEffect(a_EffectType, a_Effect);
-}
-
-
-
-
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index ca6cb0593..638d5be39 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -224,8 +224,6 @@ protected:
int m_LastGroundHeight;
/* =========================== */
-
- virtual void HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) override;
float m_IdleInterval;
float m_DestroyTimer;
--
cgit v1.2.3
From 3e15c92d18c344c95bd805d7795db990258eed5a Mon Sep 17 00:00:00 2001
From: tonibm19
Date: Fri, 20 Jun 2014 10:50:21 +0200
Subject: Added pig riding.
Now you can ride a pig using a carrot on a stick.
---
src/Mobs/Pig.cpp | 13 +++++++++++++
src/Mobs/Pig.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index e862f5aaa..ddd98eb94 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -76,5 +76,18 @@ void cPig::OnRightClicked(cPlayer & a_Player)
}
}
+void cPig::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ super::Tick(a_Dt, a_Chunk);
+
+ if (m_bIsSaddled && m_Attachee != NULL)
+ {
+ if (m_Attachee->IsPlayer() && m_Attachee->GetEquippedWeapon().m_ItemType == E_ITEM_CARROT_ON_STICK)
+ {
+ MoveToPosition((m_Attachee->GetPosition()) + (m_Attachee->GetLookVector()*10));
+ m_bMovingToDestination = true;
+ }
+ }
+}
diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h
index d434324c1..313af2f44 100644
--- a/src/Mobs/Pig.h
+++ b/src/Mobs/Pig.h
@@ -19,6 +19,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
--
cgit v1.2.3
From a908f39dde1dc8866bda1a85b8443ae4cdaaa2b4 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 21 Jun 2014 20:33:23 +0100
Subject: Rewrote furnace recipe parser
* Fixes #110
---
src/FurnaceRecipe.cpp | 252 +++++++++++++++++++++++++++++++-------------------
src/FurnaceRecipe.h | 22 +++++
2 files changed, 181 insertions(+), 93 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index bd7fd8079..b4b3d34d9 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -5,7 +5,8 @@
#include "Item.h"
#include
-#include
+
+#define FURNACE_RECIPE_FILE "furnace.txt"
@@ -53,128 +54,193 @@ void cFurnaceRecipe::ReloadRecipes(void)
ClearRecipes();
LOGD("Loading furnace recipes...");
- std::ifstream f;
- char a_File[] = "furnace.txt";
- f.open(a_File, std::ios::in);
-
- if (!f.good())
+ std::ifstream F(FURNACE_RECIPE_FILE, std::ios::in);
+ if (!F.good())
{
- f.close();
- LOG("Could not open the furnace recipes file \"%s\"", a_File);
+ F.close();
+ LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE);
return;
}
+
+ AString SyntaxError;
+ unsigned int Line = 0;
+ AString ParsingLine;
- // TODO: Replace this messy parse with a high-level-structured one (ReadLine / ProcessLine)
- bool bSyntaxError = false;
- while (f.good())
- {
- char c;
+ ASSERT(ParsingLine.empty());
- //////////////////////////////////////////////////////////////////////////
- // comments
- f >> c;
- f.unget();
- if( c == '#' )
+ while (std::getline(F, ParsingLine))
+ {
+ Line++;
+ ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove whitespace
+ if (ParsingLine.empty())
{
- while( f.good() && c != '\n' )
- {
- f.get( c );
- }
continue;
}
-
- //////////////////////////////////////////////////////////////////////////
- // Line breaks
- f.get( c );
- while( f.good() && ( c == '\n' || c == '\r' ) ) { f.get( c ); }
- if (f.eof())
+ // Comments
+ if (ParsingLine[0] == '#')
{
- break;
+ continue;
}
- f.unget();
- //////////////////////////////////////////////////////////////////////////
- // Check for fuel
- f >> c;
- if( c == '!' ) // It's fuel :)
+ if (ParsingLine[0] == '!') // Fuels start with a bang :)
{
- // Read item
- int IItemID = 0, IItemCount = 0, IItemHealth = 0;
- f >> IItemID;
- f >> c; if( c != ':' ) { bSyntaxError = true; break; }
- f >> IItemCount;
-
- // Optional health
- f >> c;
- if( c != ':' )
- f.unget();
- else
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, SyntaxError, Line, IBurnTime, true) // Read item burn time - last value
+ )
{
- f >> IItemHealth;
+ break;
}
- // Burn time
- int BurnTime;
- f >> c; if( c != '=' ) { bSyntaxError = true; break; }
- f >> BurnTime;
-
// Add to fuel list
Fuel F;
- F.In = new cItem( (ENUM_ITEM_ID) IItemID, (char)IItemCount, (short)IItemHealth );
- F.BurnTime = BurnTime;
- m_pState->Fuel.push_back( F );
+ F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ F.BurnTime = IBurnTime;
+ m_pState->Fuel.push_back(F);
+ printf("%i %i %i %i\n", IItemID, IItemCount, IItemHealth, IBurnTime);
continue;
}
- f.unget();
-
- //////////////////////////////////////////////////////////////////////////
- // Read items
- int IItemID = 0, IItemCount = 0, IItemHealth = 0;
- f >> IItemID;
- f >> c; if( c != ':' ) { bSyntaxError = true; break; }
- f >> IItemCount;
-
- // Optional health
- f >> c;
- if( c != ':' )
- f.unget();
- else
+ else if (isdigit(ParsingLine[0])) // Recipes start with a numeral :)
{
- f >> IItemHealth;
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ int OItemID = 0, OItemCount = 0, OItemHealth = 0;
+ AString::size_type BeginPos = 0; // Begin at start of line
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "=", ParsingLine, SyntaxError, Line, IBurnTime) || // Read item burn time
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, OItemID) || // Read result ID
+ !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, SyntaxError, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
+ )
+ {
+ break;
+ }
+
+ // Add to recipe list
+ Recipe R;
+ R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth);
+ R.CookTime = IBurnTime;
+ m_pState->Recipes.push_back(R);
}
+ }
+ F.close();
- int CookTime;
- f >> c; if( c != '@' ) { bSyntaxError = true; break; }
- f >> CookTime;
+ if (!SyntaxError.empty())
+ {
+ LOGWARN("Error parsing furnace recipes at %s", SyntaxError.c_str());
+ }
+ else
+ {
+ LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
+ }
+}
- int OItemID = 0, OItemCount = 0, OItemHealth = 0;
- f >> c; if( c != '=' ) { bSyntaxError = true; break; }
- f >> OItemID;
- f >> c; if( c != ':' ) { bSyntaxError = true; break; }
- f >> OItemCount;
- // Optional health
- f >> c;
- if( c != ':' )
- f.unget();
- else
+
+
+
+void cFurnaceRecipe::SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing)
+{
+ Printf(a_ErrorString, "line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
+}
+
+
+
+
+
+bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue)
+{
+ AString::size_type End;
+ if (a_IsLastValue)
+ {
+ End = a_Text.find_first_not_of(a_Delimiter, a_Begin);
+ }
+ else
+ {
+ End = a_Text.find_first_of(a_Delimiter, a_Begin);
+ if (End == AString::npos)
{
- f >> OItemHealth;
+ SetParseError(a_ErrorString, a_Line, a_Begin, a_Delimiter);
+ return false;
}
-
- // Add to recipe list
- Recipe R;
- R.In = new cItem( (ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth );
- R.Out = new cItem( (ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth );
- R.CookTime = CookTime;
- m_pState->Recipes.push_back( R );
}
- if (bSyntaxError)
+
+ // stoi won't throw an exception if the string is alphanumeric, we should check for this
+ if (!DoesStringContainOnlyNumbers(a_Text.substr(a_Begin, End - a_Begin)))
{
- LOGERROR("ERROR: FurnaceRecipe, syntax error" );
+ SetParseError(a_ErrorString, a_Line, a_Begin, "number");
+ return false;
+ }
+ a_Value = std::stoi(a_Text.substr(a_Begin, End - a_Begin));
+
+ a_Begin = End + 1; // Jump over delimiter
+ return true;
+}
+
+
+
+
+
+bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue)
+{
+ unsigned int End, Begin = a_Begin;
+
+ End = a_Text.find_first_of(a_DelimiterOne, Begin);
+ if (End != AString::npos)
+ {
+ if (DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin)))
+ {
+ a_ValueOne = std::stoi(a_Text.substr(Begin, End - Begin));
+ Begin = End + 1;
+
+ if (a_IsLastValue)
+ {
+ End = a_Text.find_first_not_of(a_DelimiterTwo, Begin);
+ }
+ else
+ {
+ End = a_Text.find_first_of(a_DelimiterTwo, Begin);
+ if (End == AString::npos)
+ {
+ SetParseError(a_ErrorString, a_Line, Begin, a_DelimiterTwo);
+ return false;
+ }
+ }
+
+ // stoi won't throw an exception if the string is alphanumeric, we should check for this
+ if (!DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin)))
+ {
+ SetParseError(a_ErrorString, a_Line, Begin, "number");
+ return false;
+ }
+ a_ValueTwo = std::stoi(a_Text.substr(Begin, End - Begin));
+
+ a_Begin = End + 1; // Jump over delimiter
+ return true;
+ }
+ else
+ {
+ return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue);
+ }
}
- LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
+
+ return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue);
+}
+
+
+
+
+
+bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String)
+{
+ return std::all_of(a_String.begin(), a_String.end(), isdigit);
}
diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h
index 2f91e9bcb..e0222f2fb 100644
--- a/src/FurnaceRecipe.h
+++ b/src/FurnaceRecipe.h
@@ -41,6 +41,28 @@ public:
private:
void ClearRecipes(void);
+ /** PrintFs the line, position, and error into an error string */
+ inline static void SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing);
+
+ /** Reads a number from a string given, starting at a given position and ending at a delimiter given
+ Updates beginning position to the delimiter found + 1, and updates the value to the one read
+ If it encounters a substring that is not fully numeric, it will call SetParseError() and return false; the caller should abort processing
+ Otherwise, the function will return true
+ */
+ static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false);
+
+ /** Reads two numbers from a string given, starting at a given position and ending at the first delimiter given, then again (with an updated position) until the second delimiter given
+ Updates beginning position to the second delimiter found + 1, and updates the values to the ones read
+ If it encounters a substring that is not fully numeric whilst reading the second value, it will call SetParseError() and return false; the caller should abort processing
+ If this happens whilst reading the first value, it will call ReadMandatoryNumber() with the appropriate position, as this may legitimately occur with the optional value and AString::find_first_of finding the incorrect delimiter. It will return the result of ReadMandatoryNumber()
+ True will be returned definitively for an optional value that is valid
+ */
+ static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false);
+
+ /** Uses std::all_of to determine if a string contains only digits */
+ inline static bool DoesStringContainOnlyNumbers(const AString & a_String);
+
+
struct sFurnaceRecipeState;
sFurnaceRecipeState * m_pState;
};
--
cgit v1.2.3
From 537467fe25386a67ef5cb9a33b9806ac2db0c894 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 21 Jun 2014 20:35:28 +0100
Subject: Removed debugging code
---
src/FurnaceRecipe.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index b4b3d34d9..ce9233bcc 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -102,7 +102,6 @@ void cFurnaceRecipe::ReloadRecipes(void)
F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
F.BurnTime = IBurnTime;
m_pState->Fuel.push_back(F);
- printf("%i %i %i %i\n", IItemID, IItemCount, IItemHealth, IBurnTime);
continue;
}
else if (isdigit(ParsingLine[0])) // Recipes start with a numeral :)
--
cgit v1.2.3
From 4a01fba3aafef53ac8015bd5f6028fc677d6d245 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 22 Jun 2014 00:06:58 +0100
Subject: Suggestions
---
src/FurnaceRecipe.cpp | 62 +++++++++++++++++++++------------------------------
src/FurnaceRecipe.h | 8 +++----
2 files changed, 30 insertions(+), 40 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index ce9233bcc..448a4bfa8 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -54,21 +54,18 @@ void cFurnaceRecipe::ReloadRecipes(void)
ClearRecipes();
LOGD("Loading furnace recipes...");
- std::ifstream F(FURNACE_RECIPE_FILE, std::ios::in);
- if (!F.good())
+ std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in);
+ if (!f.good())
{
- F.close();
+ f.close();
LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE);
return;
}
- AString SyntaxError;
unsigned int Line = 0;
AString ParsingLine;
- ASSERT(ParsingLine.empty());
-
- while (std::getline(F, ParsingLine))
+ while (std::getline(f, ParsingLine))
{
Line++;
ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove whitespace
@@ -89,12 +86,12 @@ void cFurnaceRecipe::ReloadRecipes(void)
AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
if (
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID
- !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
- !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, SyntaxError, Line, IBurnTime, true) // Read item burn time - last value
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value
)
{
- break;
+ return;
}
// Add to fuel list
@@ -111,14 +108,14 @@ void cFurnaceRecipe::ReloadRecipes(void)
AString::size_type BeginPos = 0; // Begin at start of line
if (
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, IItemID) || // Read item ID
- !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, SyntaxError, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
- !ReadMandatoryNumber(BeginPos, "=", ParsingLine, SyntaxError, Line, IBurnTime) || // Read item burn time
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, SyntaxError, Line, OItemID) || // Read result ID
- !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, SyntaxError, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID
+ !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
)
{
- break;
+ return;
}
// Add to recipe list
@@ -129,32 +126,25 @@ void cFurnaceRecipe::ReloadRecipes(void)
m_pState->Recipes.push_back(R);
}
}
- F.close();
+ f.close();
- if (!SyntaxError.empty())
- {
- LOGWARN("Error parsing furnace recipes at %s", SyntaxError.c_str());
- }
- else
- {
- LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
- }
+ LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
}
-void cFurnaceRecipe::SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing)
+void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing)
{
- Printf(a_ErrorString, "line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
+ LOGWARN("Error parsing furnace recipes at line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
}
-bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue)
+bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue)
{
AString::size_type End;
if (a_IsLastValue)
@@ -166,7 +156,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
End = a_Text.find_first_of(a_Delimiter, a_Begin);
if (End == AString::npos)
{
- SetParseError(a_ErrorString, a_Line, a_Begin, a_Delimiter);
+ PrintParseError(a_Line, a_Begin, a_Delimiter);
return false;
}
}
@@ -174,7 +164,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
// stoi won't throw an exception if the string is alphanumeric, we should check for this
if (!DoesStringContainOnlyNumbers(a_Text.substr(a_Begin, End - a_Begin)))
{
- SetParseError(a_ErrorString, a_Line, a_Begin, "number");
+ PrintParseError(a_Line, a_Begin, "number");
return false;
}
a_Value = std::stoi(a_Text.substr(a_Begin, End - a_Begin));
@@ -187,7 +177,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
-bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue)
+bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue)
{
unsigned int End, Begin = a_Begin;
@@ -208,7 +198,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
End = a_Text.find_first_of(a_DelimiterTwo, Begin);
if (End == AString::npos)
{
- SetParseError(a_ErrorString, a_Line, Begin, a_DelimiterTwo);
+ PrintParseError(a_Line, Begin, a_DelimiterTwo);
return false;
}
}
@@ -216,7 +206,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
// stoi won't throw an exception if the string is alphanumeric, we should check for this
if (!DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin)))
{
- SetParseError(a_ErrorString, a_Line, Begin, "number");
+ PrintParseError(a_Line, Begin, "number");
return false;
}
a_ValueTwo = std::stoi(a_Text.substr(Begin, End - Begin));
@@ -226,11 +216,11 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
}
else
{
- return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue);
+ return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_Line, a_ValueOne, a_IsLastValue);
}
}
- return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_ErrorString, a_Line, a_ValueOne, a_IsLastValue);
+ return ReadMandatoryNumber(a_Begin, a_DelimiterTwo, a_Text, a_Line, a_ValueOne, a_IsLastValue);
}
diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h
index e0222f2fb..cddcc215f 100644
--- a/src/FurnaceRecipe.h
+++ b/src/FurnaceRecipe.h
@@ -41,15 +41,15 @@ public:
private:
void ClearRecipes(void);
- /** PrintFs the line, position, and error into an error string */
- inline static void SetParseError(AString & a_ErrorString, unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing);
+ /** Calls LOGWARN with the line, position, and error */
+ inline static void PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing);
/** Reads a number from a string given, starting at a given position and ending at a delimiter given
Updates beginning position to the delimiter found + 1, and updates the value to the one read
If it encounters a substring that is not fully numeric, it will call SetParseError() and return false; the caller should abort processing
Otherwise, the function will return true
*/
- static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false);
+ static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false);
/** Reads two numbers from a string given, starting at a given position and ending at the first delimiter given, then again (with an updated position) until the second delimiter given
Updates beginning position to the second delimiter found + 1, and updates the values to the ones read
@@ -57,7 +57,7 @@ private:
If this happens whilst reading the first value, it will call ReadMandatoryNumber() with the appropriate position, as this may legitimately occur with the optional value and AString::find_first_of finding the incorrect delimiter. It will return the result of ReadMandatoryNumber()
True will be returned definitively for an optional value that is valid
*/
- static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, AString & a_ErrorString, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false);
+ static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false);
/** Uses std::all_of to determine if a string contains only digits */
inline static bool DoesStringContainOnlyNumbers(const AString & a_String);
--
cgit v1.2.3
From 63ce2e8b37444f96d7892d555cb296947b3afbe5 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 22 Jun 2014 12:30:37 +0100
Subject: Fixed compile errors
---
src/FurnaceRecipe.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index 448a4bfa8..8040552cc 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -137,7 +137,7 @@ void cFurnaceRecipe::ReloadRecipes(void)
void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing)
{
- LOGWARN("Error parsing furnace recipes at line %i pos %i: missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
+ LOGWARN("Error parsing furnace recipes at line %i pos " SIZE_T_FMT ": missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
}
@@ -179,7 +179,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue)
{
- unsigned int End, Begin = a_Begin;
+ AString::size_type End, Begin = a_Begin;
End = a_Text.find_first_of(a_DelimiterOne, Begin);
if (End != AString::npos)
--
cgit v1.2.3
From 33cc1f2a50d870b7d264ee5479068f8eee3aa458 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 22 Jun 2014 20:44:01 +0100
Subject: Fixed multiple issues with projectiles
* Fixed arrows not being collectable/not truly hitting a block/not
lodging into blocks/not going in far enough
* Fixed projectiles not playing their block hit animation owning to
being destroyed too quickly
---
src/Entities/ArrowEntity.cpp | 33 +++++-------------
src/Entities/ProjectileEntity.cpp | 61 ++++++++++++++++++---------------
src/Entities/ThrownEggEntity.cpp | 7 ++--
src/Entities/ThrownEggEntity.h | 18 ++++++++++
src/Entities/ThrownEnderPearlEntity.cpp | 9 ++---
src/Entities/ThrownEnderPearlEntity.h | 22 ++++++++++--
src/Entities/ThrownSnowballEntity.cpp | 7 ++--
src/Entities/ThrownSnowballEntity.h | 18 ++++++++++
8 files changed, 112 insertions(+), 63 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 8d2569125..db9dc781a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -68,25 +68,16 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- if (a_HitFace == BLOCK_FACE_NONE) { return; }
-
- super::OnHitSolidBlock(a_HitPos, a_HitFace);
- int a_X = (int)a_HitPos.x, a_Y = (int)a_HitPos.y, a_Z = (int)a_HitPos.z;
-
- switch (a_HitFace)
- {
- case BLOCK_FACE_XM: // Strangely, bounding boxes / block tracers return the actual block for these two directions, so AddFace not needed
- case BLOCK_FACE_YM:
- {
- break;
- }
- default: AddFaceDirection(a_X, a_Y, a_Z, a_HitFace, true);
- }
+ Vector3d Hit = a_HitPos;
+ Hit += GetSpeed() / 700; // Make arrow sink into block a little
+
+ super::OnHitSolidBlock(Hit, a_HitFace);
+ int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z);
- m_HitBlockPos = Vector3i(a_X, a_Y, a_Z);
+ m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
- m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.bowhit", X * 8, Y * 8, Z * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
@@ -94,13 +85,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
-{
- if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat())
- {
- // Not an entity that interacts with an arrow
- return;
- }
-
+{
int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
if (m_IsCritical)
{
@@ -165,7 +150,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
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
+ if (m_HitGroundTimer > 500.f) // Send after half a second, could be less, but just in case
{
m_World->BroadcastTeleportEntity(*this);
m_HasTeleported = true;
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 95c494569..d45f1d212 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -67,16 +67,17 @@ protected:
if (cBlockInfo::IsSolid(a_BlockType))
{
- // The projectile hit a solid block
- // Calculate the exact hit coords:
- cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1);
- Vector3d Line1 = m_Projectile->GetPosition();
- Vector3d Line2 = Line1 + m_Projectile->GetSpeed();
- double LineCoeff = 0;
- eBlockFace Face;
- if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face))
+ // The projectile hit a solid block, calculate the exact hit coords:
+ cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit
+ const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit
+ const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit
+ double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs
+ eBlockFace Face; // Face hit
+
+ if (bb.CalcLineIntersection(LineStart, LineEnd, LineCoeff, Face))
{
- Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff;
+ Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block
+
if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection))
{
return false;
@@ -161,7 +162,12 @@ public:
return false;
}
- // TODO: Some entities don't interact with the projectiles (pickups, falling blocks)
+ if (!a_Entity->IsMob() && !a_Entity->IsMinecart() && !a_Entity->IsPlayer() && !a_Entity->IsBoat())
+ {
+ // Not an entity that interacts with a projectile
+ return false;
+ }
+
if (cPluginManager::Get()->CallHookProjectileHitEntity(*m_Projectile, *a_Entity))
{
// A plugin disagreed.
@@ -316,8 +322,9 @@ AString cProjectileEntity::GetMCAClassName(void) const
void cProjectileEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
-
- if (GetProjectileKind() != pkArrow) // See cArrow::Tick
+
+ // TODO: see BroadcastMovementUpdate; RelativeMove packet jerkiness affects projectiles too (cause of sympton described in cArrowEntity::Tick())
+ if (GetProjectileKind() != pkArrow)
{
BroadcastMovementUpdate();
}
@@ -335,19 +342,10 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
return;
}
- Vector3d PerTickSpeed = GetSpeed() / 20;
- Vector3d Pos = GetPosition();
-
- // Trace the tick's worth of movement as a line:
- Vector3d NextPos = Pos + PerTickSpeed;
- cProjectileTracerCallback TracerCallback(this);
- if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos))
- {
- // Something has been hit, abort all other processing
- return;
- }
- // The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff
-
+ const Vector3d PerTickSpeed = GetSpeed() / 20;
+ const Vector3d Pos = GetPosition();
+ const Vector3d NextPos = Pos + PerTickSpeed;
+
// Test for entity collisions:
cProjectileEntityCollisionCallback EntityCollisionCallback(this, Pos, NextPos);
a_Chunk.ForEachEntity(EntityCollisionCallback);
@@ -363,11 +361,20 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
EntityCollisionCallback.GetHitEntity()->GetClass(),
HitPos.x, HitPos.y, HitPos.z,
EntityCollisionCallback.GetMinCoeff()
- );
-
+ );
+
OnHitEntity(*(EntityCollisionCallback.GetHitEntity()), HitPos);
}
// TODO: Test the entities in the neighboring chunks, too
+
+ // Trace the tick's worth of movement as a line:
+ cProjectileTracerCallback TracerCallback(this);
+ if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos))
+ {
+ // Something has been hit, abort all other processing
+ return;
+ }
+ // The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff
// Update the position:
SetPosition(NextPos);
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 224019091..d7eed41e3 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -8,7 +8,8 @@
cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -21,7 +22,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
{
TrySpawnChicken(a_HitPos);
- Destroy();
+ m_DestroyTimer = 5;
}
@@ -36,7 +37,7 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
TrySpawnChicken(a_HitPos);
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- Destroy(true);
+ m_DestroyTimer = 5;
}
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index 5ba8f051b..894665428 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -30,8 +30,26 @@ 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;
+ virtual void Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else { super::Tick(a_Dt, a_Chunk); }
+ }
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
+
+private:
+
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
} ; // tolua_export
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index c37161145..a3ee23389 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -7,7 +7,8 @@
cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -21,7 +22,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF
// TODO: Tweak a_HitPos based on block face.
TeleportCreator(a_HitPos);
- Destroy();
+ m_DestroyTimer = 5;
}
@@ -36,7 +37,7 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
TeleportCreator(a_HitPos);
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- Destroy(true);
+ m_DestroyTimer = 5;
}
@@ -48,7 +49,7 @@ void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
// Teleport the creator here, make them take 5 damage:
if (m_Creator != NULL)
{
- m_Creator->TeleportToCoords(a_HitPos.x + 0.5, a_HitPos.y + 1.7, a_HitPos.z + 0.5);
+ m_Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z);
m_Creator->TakeDamage(dtEnderPearl, this, 5, 0);
}
}
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index ddee5babe..bfd9bd70d 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -30,8 +30,26 @@ 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.
+ virtual void Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else { super::Tick(a_Dt, a_Chunk); }
+ }
+
+ /** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
+
+private:
+
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
} ; // tolua_export
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index cefc3433c..b82cd56db 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -8,7 +8,8 @@
cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -19,7 +20,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do
void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- Destroy();
+ m_DestroyTimer = 5;
}
@@ -40,5 +41,5 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
// TODO: If entity is Ender Crystal, destroy it
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- Destroy(true);
+ m_DestroyTimer = 5;
}
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index a09512e37..e30971f0a 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -30,5 +30,23 @@ 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;
+ virtual void Tick (float a_Dt, cChunk & a_Chunk) override
+ {
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else { super::Tick(a_Dt, a_Chunk); }
+ }
+
+private:
+
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
} ; // tolua_export
--
cgit v1.2.3
From 4238b0ebe8d910186d4e160222f337b6e8b33cc8 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 22 Jun 2014 20:44:18 +0100
Subject: Some Entity.cpp style improvements
---
src/Entities/Entity.cpp | 17 ++++++-----------
src/Entities/Entity.h | 4 ++--
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index ee7ce06ac..f4e89367b 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -255,8 +255,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
void cEntity::SetYawFromSpeed(void)
{
- const double EPS = 0.0000001;
- if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS))
+ if ((abs(m_Speed.x) < std::numeric_limits::epsilon()) && (abs(m_Speed.z) < std::numeric_limits::epsilon()))
{
// atan2() may overflow or is undefined, pick any number
SetYaw(0);
@@ -1236,7 +1235,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
if (GetWorld()->GetWorldAge() % 2 == 0)
{
double SpeedSqr = GetSpeed().SqrLength();
- if (SpeedSqr == 0.0)
+ if (SpeedSqr < std::numeric_limits::epsilon())
{
// Speed is zero, send this to clients once only as well as an absolute position
if (!m_bHasSentNoSpeed)
@@ -1476,8 +1475,7 @@ void cEntity::SetWidth(double a_Width)
void cEntity::AddPosX(double a_AddPosX)
{
- m_Pos.x += a_AddPosX;
-
+ m_Pos.x += a_AddPosX;
}
@@ -1485,8 +1483,7 @@ void cEntity::AddPosX(double a_AddPosX)
void cEntity::AddPosY(double a_AddPosY)
{
- m_Pos.y += a_AddPosY;
-
+ m_Pos.y += a_AddPosY;
}
@@ -1494,8 +1491,7 @@ void cEntity::AddPosY(double a_AddPosY)
void cEntity::AddPosZ(double a_AddPosZ)
{
- m_Pos.z += a_AddPosZ;
-
+ m_Pos.z += a_AddPosZ;
}
@@ -1505,8 +1501,7 @@ void cEntity::AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ)
{
m_Pos.x += a_AddPosX;
m_Pos.y += a_AddPosY;
- m_Pos.z += a_AddPosZ;
-
+ m_Pos.z += a_AddPosZ;
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 2df66e353..f4080f8aa 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -237,9 +237,9 @@ public:
void AddPosY (double a_AddPosY);
void AddPosZ (double a_AddPosZ);
void AddPosition(double a_AddPosX, double a_AddPosY, double a_AddPosZ);
- void AddPosition(const Vector3d & a_AddPos) { AddPosition(a_AddPos.x,a_AddPos.y,a_AddPos.z);}
+ void AddPosition(const Vector3d & a_AddPos) { AddPosition(a_AddPos.x, a_AddPos.y, a_AddPos.z); }
void AddSpeed (double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ);
- void AddSpeed (const Vector3d & a_AddSpeed) { AddSpeed(a_AddSpeed.x,a_AddSpeed.y,a_AddSpeed.z);}
+ void AddSpeed (const Vector3d & a_AddSpeed) { AddSpeed(a_AddSpeed.x, a_AddSpeed.y, a_AddSpeed.z); }
void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ);
--
cgit v1.2.3
From dad0037f987df594d6a1971af5b29f89c2d27901 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 22 Jun 2014 20:44:55 +0100
Subject: Bettered zombie and skeleton AI
* Fixed potential issues with skylight detection
---
src/Mobs/Skeleton.cpp | 5 ++---
src/Mobs/Zombie.cpp | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index e3357185d..0641a3d57 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -49,11 +49,10 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSkeleton::MoveToPosition(const Vector3f & a_Position)
{
- // If the destination is in the sun and if it is not night AND the skeleton isn't on fire then block the movement.
+ // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
!IsOnFire() &&
- (m_World->GetTimeOfDay() < 13187) &&
- (m_World->GetBlockSkyLight((int) a_Position.x, (int) a_Position.y, (int) a_Position.z) == 15)
+ (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8)
)
{
m_bMovingToDestination = false;
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index f19e096ee..725790ed9 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -44,11 +44,10 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cZombie::MoveToPosition(const Vector3f & a_Position)
{
- // If the destination is in the sun and if it is not night AND the zombie isn't on fire then block the movement.
+ // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement
if (
!IsOnFire() &&
- (m_World->GetTimeOfDay() < 13187) &&
- (m_World->GetBlockSkyLight((int)a_Position.x, (int)a_Position.y, (int)a_Position.z) == 15)
+ (m_World->GetBlockSkyLight((int)floor(a_Position.x), (int)floor(a_Position.y), (int)floor(a_Position.z)) - m_World->GetSkyDarkness() > 8)
)
{
m_bMovingToDestination = false;
--
cgit v1.2.3
From c476fc3cf5a2bbdb27b61fcad290c84029721462 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 22 Jun 2014 21:49:37 +0100
Subject: Suggestions
---
src/FurnaceRecipe.cpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index 448a4bfa8..90b478285 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -57,7 +57,6 @@ void cFurnaceRecipe::ReloadRecipes(void)
std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in);
if (!f.good())
{
- f.close();
LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE);
return;
}
@@ -126,7 +125,6 @@ void cFurnaceRecipe::ReloadRecipes(void)
m_pState->Recipes.push_back(R);
}
}
- f.close();
LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
}
@@ -146,6 +144,7 @@ void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, con
bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue)
{
+ // TODO: replace atoi with std::stoi
AString::size_type End;
if (a_IsLastValue)
{
@@ -167,7 +166,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
PrintParseError(a_Line, a_Begin, "number");
return false;
}
- a_Value = std::stoi(a_Text.substr(a_Begin, End - a_Begin));
+ a_Value = atoi(a_Text.substr(a_Begin, End - a_Begin).c_str());
a_Begin = End + 1; // Jump over delimiter
return true;
@@ -179,6 +178,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue)
{
+ // TODO: replace atoi with std::stoi
unsigned int End, Begin = a_Begin;
End = a_Text.find_first_of(a_DelimiterOne, Begin);
@@ -186,7 +186,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
{
if (DoesStringContainOnlyNumbers(a_Text.substr(Begin, End - Begin)))
{
- a_ValueOne = std::stoi(a_Text.substr(Begin, End - Begin));
+ a_ValueOne = std::atoi(a_Text.substr(Begin, End - Begin).c_str());
Begin = End + 1;
if (a_IsLastValue)
@@ -209,7 +209,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
PrintParseError(a_Line, Begin, "number");
return false;
}
- a_ValueTwo = std::stoi(a_Text.substr(Begin, End - Begin));
+ a_ValueTwo = atoi(a_Text.substr(Begin, End - Begin).c_str());
a_Begin = End + 1; // Jump over delimiter
return true;
@@ -229,7 +229,8 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String)
{
- return std::all_of(a_String.begin(), a_String.end(), isdigit);
+ // TODO: replace this with std::all_of(a_String.begin(), a_String.end(), isdigit)
+ return a_String.find_first_not_of("0123456789") == AString::npos;
}
--
cgit v1.2.3
From 7a236921319c44de38246ff73d5343e174dd560f Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 23 Jun 2014 17:40:51 +0100
Subject: Parenthesised comparison
---
src/FurnaceRecipe.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index d53854950..36dd2d5e9 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -230,7 +230,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
bool cFurnaceRecipe::DoesStringContainOnlyNumbers(const AString & a_String)
{
// TODO: replace this with std::all_of(a_String.begin(), a_String.end(), isdigit)
- return a_String.find_first_not_of("0123456789") == AString::npos;
+ return (a_String.find_first_not_of("0123456789") == AString::npos);
}
--
cgit v1.2.3
From e96a774f59305914af01bdd4b264e0fe37988463 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 24 Jun 2014 14:48:18 +0200
Subject: Added the Lua Proxy DLL.
This builds the lua5.1.dll file on Windows, making it 64-bit if so required.
---
CMakeLists.txt | 4 ++
MCServer/lua5.1.dll | Bin 6722 -> 0 bytes
lib/luaproxy/CMakeLists.txt | 58 ++++++++++++++++++
lib/luaproxy/Dummy.c | 4 ++
lib/luaproxy/lua5.1.def | 115 ++++++++++++++++++++++++++++++++++++
lib/luaproxy/lua5.1.lua | 140 ++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 321 insertions(+)
delete mode 100644 MCServer/lua5.1.dll
create mode 100644 lib/luaproxy/CMakeLists.txt
create mode 100644 lib/luaproxy/Dummy.c
create mode 100644 lib/luaproxy/lua5.1.def
create mode 100644 lib/luaproxy/lua5.1.lua
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56dea1a34..a15ec5069 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,10 @@ add_subdirectory(lib/expat/)
add_subdirectory(lib/luaexpat/)
add_subdirectory(lib/md5/)
+if (WIN32)
+ add_subdirectory(lib/luaproxy/)
+endif()
+
# We use EXCLUDE_FROM_ALL so that only the explicit dependencies are used
# (PolarSSL also has test and example programs in their CMakeLists.txt, we don't want those)
diff --git a/MCServer/lua5.1.dll b/MCServer/lua5.1.dll
deleted file mode 100644
index cca0bcb25..000000000
Binary files a/MCServer/lua5.1.dll and /dev/null differ
diff --git a/lib/luaproxy/CMakeLists.txt b/lib/luaproxy/CMakeLists.txt
new file mode 100644
index 000000000..f115036e1
--- /dev/null
+++ b/lib/luaproxy/CMakeLists.txt
@@ -0,0 +1,58 @@
+
+# This project adds a Lua Proxy DLL on Windows
+# By an unfortunate choice in the popular LuaBinaries distribution, there are two names for the Lua DLL on Windows: lua51.dll and lua5.1.dll.
+# Some binary Lua packages are built for one, the others for the other. Messy!
+# In order to support both package flavors, we create a "proxy DLL":
+# Basically the lua5.1.dll has its PE Exports section manipulated so that it points each exported function to its lua51.dll implementation.
+# Effectively, this forwards all calls from lua5.1.dll to lua51.dll without any performance costs (the forwarding is done in the Windows PE loader on app start).
+
+# This project creates the proxy DLL by using a specially crafted .DEF file that is used to link the Proxy DLL.
+# Note that it has been tested only on MSVC, it might not work with other compilers.
+# The initial implementation was taken from http://lua-users.org/wiki/LuaProxyDllFour , but adapted to MSVC
+
+
+
+
+if (WIN32)
+
+ if (MSVC)
+ # Tell the linker to use the DEF file to generate the proxy:
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ else()
+ message ("This code has not been tested on your compiler. Please report your success or failure in the forum.")
+ endif()
+
+ add_library(luaproxy SHARED "lua5.1.def" "Dummy.c")
+ set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
+ set_target_properties(luaproxy PROPERTIES
+ OUTPUT_NAME "lua5.1"
+ )
+ target_link_libraries(luaproxy lua)
+
+ # Output the executable into the $/MCServer folder, so that MCServer can find it:
+ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
+ SET_TARGET_PROPERTIES(luaproxy PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
+ ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
+ ARCHIVE_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
+ ARCHIVE_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
+ LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
+ LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
+ LIBRARY_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
+ LIBRARY_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
+ RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
+ RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
+ RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
+ )
+
+else()
+
+ message (FATAL_ERROR "This project is needed only for Windows, modify your cmake file not to include it on Linux")
+
+endif()
diff --git a/lib/luaproxy/Dummy.c b/lib/luaproxy/Dummy.c
new file mode 100644
index 000000000..4018d8392
--- /dev/null
+++ b/lib/luaproxy/Dummy.c
@@ -0,0 +1,4 @@
+
+// Dummy.c
+
+// Because the MSVC compiler needs at least one C file to compile the project
diff --git a/lib/luaproxy/lua5.1.def b/lib/luaproxy/lua5.1.def
new file mode 100644
index 000000000..42986d22f
--- /dev/null
+++ b/lib/luaproxy/lua5.1.def
@@ -0,0 +1,115 @@
+EXPORTS
+ luaL_addlstring=lua51.luaL_addlstring
+ luaL_addstring=lua51.luaL_addstring
+ luaL_addvalue=lua51.luaL_addvalue
+ luaL_argerror=lua51.luaL_argerror
+ luaL_buffinit=lua51.luaL_buffinit
+ luaL_callmeta=lua51.luaL_callmeta
+ luaL_checkany=lua51.luaL_checkany
+ luaL_checkinteger=lua51.luaL_checkinteger
+ luaL_checklstring=lua51.luaL_checklstring
+ luaL_checknumber=lua51.luaL_checknumber
+ luaL_checkoption=lua51.luaL_checkoption
+ luaL_checkstack=lua51.luaL_checkstack
+ luaL_checktype=lua51.luaL_checktype
+ luaL_checkudata=lua51.luaL_checkudata
+ luaL_error=lua51.luaL_error
+ luaL_findtable=lua51.luaL_findtable
+ luaL_getmetafield=lua51.luaL_getmetafield
+ luaL_gsub=lua51.luaL_gsub
+ luaL_loadbuffer=lua51.luaL_loadbuffer
+ luaL_loadfile=lua51.luaL_loadfile
+ luaL_loadstring=lua51.luaL_loadstring
+ luaL_newmetatable=lua51.luaL_newmetatable
+ luaL_newstate=lua51.luaL_newstate
+ luaL_openlib=lua51.luaL_openlib
+ luaL_openlibs=lua51.luaL_openlibs
+ luaL_optinteger=lua51.luaL_optinteger
+ luaL_optlstring=lua51.luaL_optlstring
+ luaL_optnumber=lua51.luaL_optnumber
+ luaL_prepbuffer=lua51.luaL_prepbuffer
+ luaL_pushresult=lua51.luaL_pushresult
+ luaL_ref=lua51.luaL_ref
+ luaL_register=lua51.luaL_register
+ luaL_typerror=lua51.luaL_typerror
+ luaL_unref=lua51.luaL_unref
+ luaL_where=lua51.luaL_where
+ lua_atpanic=lua51.lua_atpanic
+ lua_call=lua51.lua_call
+ lua_checkstack=lua51.lua_checkstack
+ lua_close=lua51.lua_close
+ lua_concat=lua51.lua_concat
+ lua_cpcall=lua51.lua_cpcall
+ lua_createtable=lua51.lua_createtable
+ lua_dump=lua51.lua_dump
+ lua_equal=lua51.lua_equal
+ lua_error=lua51.lua_error
+ lua_gc=lua51.lua_gc
+ lua_getallocf=lua51.lua_getallocf
+ lua_getfenv=lua51.lua_getfenv
+ lua_getfield=lua51.lua_getfield
+ lua_gethook=lua51.lua_gethook
+ lua_gethookcount=lua51.lua_gethookcount
+ lua_gethookmask=lua51.lua_gethookmask
+ lua_getinfo=lua51.lua_getinfo
+ lua_getlocal=lua51.lua_getlocal
+ lua_getmetatable=lua51.lua_getmetatable
+ lua_getstack=lua51.lua_getstack
+ lua_gettable=lua51.lua_gettable
+ lua_gettop=lua51.lua_gettop
+ lua_getupvalue=lua51.lua_getupvalue
+ lua_insert=lua51.lua_insert
+ lua_iscfunction=lua51.lua_iscfunction
+ lua_isnumber=lua51.lua_isnumber
+ lua_isstring=lua51.lua_isstring
+ lua_isuserdata=lua51.lua_isuserdata
+ lua_lessthan=lua51.lua_lessthan
+ lua_load=lua51.lua_load
+ lua_newstate=lua51.lua_newstate
+ lua_newthread=lua51.lua_newthread
+ lua_newuserdata=lua51.lua_newuserdata
+ lua_next=lua51.lua_next
+ lua_objlen=lua51.lua_objlen
+ lua_pcall=lua51.lua_pcall
+ lua_pushboolean=lua51.lua_pushboolean
+ lua_pushcclosure=lua51.lua_pushcclosure
+ lua_pushfstring=lua51.lua_pushfstring
+ lua_pushinteger=lua51.lua_pushinteger
+ lua_pushlightuserdata=lua51.lua_pushlightuserdata
+ lua_pushlstring=lua51.lua_pushlstring
+ lua_pushnil=lua51.lua_pushnil
+ lua_pushnumber=lua51.lua_pushnumber
+ lua_pushstring=lua51.lua_pushstring
+ lua_pushthread=lua51.lua_pushthread
+ lua_pushvalue=lua51.lua_pushvalue
+ lua_pushvfstring=lua51.lua_pushvfstring
+ lua_rawequal=lua51.lua_rawequal
+ lua_rawget=lua51.lua_rawget
+ lua_rawgeti=lua51.lua_rawgeti
+ lua_rawset=lua51.lua_rawset
+ lua_rawseti=lua51.lua_rawseti
+ lua_remove=lua51.lua_remove
+ lua_replace=lua51.lua_replace
+ lua_resume=lua51.lua_resume
+ lua_setallocf=lua51.lua_setallocf
+ lua_setfenv=lua51.lua_setfenv
+ lua_setfield=lua51.lua_setfield
+ lua_sethook=lua51.lua_sethook
+ lua_setlocal=lua51.lua_setlocal
+ lua_setmetatable=lua51.lua_setmetatable
+ lua_settable=lua51.lua_settable
+ lua_settop=lua51.lua_settop
+ lua_setupvalue=lua51.lua_setupvalue
+ lua_status=lua51.lua_status
+ lua_toboolean=lua51.lua_toboolean
+ lua_tocfunction=lua51.lua_tocfunction
+ lua_tointeger=lua51.lua_tointeger
+ lua_tolstring=lua51.lua_tolstring
+ lua_tonumber=lua51.lua_tonumber
+ lua_topointer=lua51.lua_topointer
+ lua_tothread=lua51.lua_tothread
+ lua_touserdata=lua51.lua_touserdata
+ lua_type=lua51.lua_type
+ lua_typename=lua51.lua_typename
+ lua_xmove=lua51.lua_xmove
+ lua_yield=lua51.lua_yield
diff --git a/lib/luaproxy/lua5.1.lua b/lib/luaproxy/lua5.1.lua
new file mode 100644
index 000000000..bda84641a
--- /dev/null
+++ b/lib/luaproxy/lua5.1.lua
@@ -0,0 +1,140 @@
+
+-- lua5.1.lua
+-- Generates the lua5.1.def file from the list of Lua symbols below
+
+
+
+
+
+local symbols =
+{
+ "luaL_addlstring",
+ "luaL_addstring",
+ "luaL_addvalue",
+ "luaL_argerror",
+ "luaL_buffinit",
+ "luaL_callmeta",
+ "luaL_checkany",
+ "luaL_checkinteger",
+ "luaL_checklstring",
+ "luaL_checknumber",
+ "luaL_checkoption",
+ "luaL_checkstack",
+ "luaL_checktype",
+ "luaL_checkudata",
+ "luaL_error",
+ "luaL_findtable",
+ "luaL_getmetafield",
+ "luaL_gsub",
+ "luaL_loadbuffer",
+ "luaL_loadfile",
+ "luaL_loadstring",
+ "luaL_newmetatable",
+ "luaL_newstate",
+ "luaL_openlib",
+ "luaL_openlibs",
+ "luaL_optinteger",
+ "luaL_optlstring",
+ "luaL_optnumber",
+ "luaL_prepbuffer",
+ "luaL_pushresult",
+ "luaL_ref",
+ "luaL_register",
+ "luaL_typerror",
+ "luaL_unref",
+ "luaL_where",
+ "lua_atpanic",
+ "lua_call",
+ "lua_checkstack",
+ "lua_close",
+ "lua_concat",
+ "lua_cpcall",
+ "lua_createtable",
+ "lua_dump",
+ "lua_equal",
+ "lua_error",
+ "lua_gc",
+ "lua_getallocf",
+ "lua_getfenv",
+ "lua_getfield",
+ "lua_gethook",
+ "lua_gethookcount",
+ "lua_gethookmask",
+ "lua_getinfo",
+ "lua_getlocal",
+ "lua_getmetatable",
+ "lua_getstack",
+ "lua_gettable",
+ "lua_gettop",
+ "lua_getupvalue",
+ "lua_insert",
+ "lua_iscfunction",
+ "lua_isnumber",
+ "lua_isstring",
+ "lua_isuserdata",
+ "lua_lessthan",
+ "lua_load",
+ "lua_newstate",
+ "lua_newthread",
+ "lua_newuserdata",
+ "lua_next",
+ "lua_objlen",
+ "lua_pcall",
+ "lua_pushboolean",
+ "lua_pushcclosure",
+ "lua_pushfstring",
+ "lua_pushinteger",
+ "lua_pushlightuserdata",
+ "lua_pushlstring",
+ "lua_pushnil",
+ "lua_pushnumber",
+ "lua_pushstring",
+ "lua_pushthread",
+ "lua_pushvalue",
+ "lua_pushvfstring",
+ "lua_rawequal",
+ "lua_rawget",
+ "lua_rawgeti",
+ "lua_rawset",
+ "lua_rawseti",
+ "lua_remove",
+ "lua_replace",
+ "lua_resume",
+ "lua_setallocf",
+ "lua_setfenv",
+ "lua_setfield",
+ "lua_sethook",
+ "lua_setlocal",
+ "lua_setmetatable",
+ "lua_settable",
+ "lua_settop",
+ "lua_setupvalue",
+ "lua_status",
+ "lua_toboolean",
+ "lua_tocfunction",
+ "lua_tointeger",
+ "lua_tolstring",
+ "lua_tonumber",
+ "lua_topointer",
+ "lua_tothread",
+ "lua_touserdata",
+ "lua_type",
+ "lua_typename",
+ "lua_xmove",
+ "lua_yield",
+ -- "luaopen_base",
+ -- "luaopen_debug",
+ -- "luaopen_io",
+ -- "luaopen_math",
+ -- "luaopen_os",
+ -- "luaopen_package",
+ -- "luaopen_string",
+ -- "luaopen_table",
+}
+
+local def = io.open("lua5.1.def", "w")
+def:write("EXPORTS\n")
+for _,symbol in ipairs(symbols) do
+ def:write("\t" .. symbol .. "=lua51." .. symbol .. "\n")
+end
+def:close()
\ No newline at end of file
--
cgit v1.2.3
From dc284783f0698ad18601ba4ccba07646901b7de9 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 24 Jun 2014 14:49:35 +0200
Subject: Added a missing endline.
---
lib/luaproxy/lua5.1.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/luaproxy/lua5.1.lua b/lib/luaproxy/lua5.1.lua
index bda84641a..b826e12d0 100644
--- a/lib/luaproxy/lua5.1.lua
+++ b/lib/luaproxy/lua5.1.lua
@@ -137,4 +137,4 @@ def:write("EXPORTS\n")
for _,symbol in ipairs(symbols) do
def:write("\t" .. symbol .. "=lua51." .. symbol .. "\n")
end
-def:close()
\ No newline at end of file
+def:close()
--
cgit v1.2.3
From 5ab01c4d4205b61b41855eaeee534ae15b816331 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 24 Jun 2014 15:27:19 +0200
Subject: Fix pickup combining over the maximum stack size.
---
src/Entities/Pickup.cpp | 12 ++++++++----
src/Item.cpp | 2 +-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 0fd006485..88d961106 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -38,11 +38,15 @@ public:
Vector3d EntityPos = a_Entity->GetPosition();
double Distance = (EntityPos - m_Position).Length();
- if ((Distance < 1.2) && ((cPickup *)a_Entity)->GetItem().IsEqual(m_Pickup->GetItem()))
+ cItem & Item = ((cPickup *)a_Entity)->GetItem();
+ if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()))
{
- m_Pickup->GetItem().AddCount(((cPickup *)a_Entity)->GetItem().m_ItemCount);
- a_Entity->Destroy();
- m_FoundMatchingPickup = true;
+ if ((Item.m_ItemCount + m_Pickup->GetItem().m_ItemCount) <= Item.GetMaxStackSize())
+ {
+ m_Pickup->GetItem().AddCount(Item.m_ItemCount);
+ a_Entity->Destroy();
+ m_FoundMatchingPickup = true;
+ }
}
return false;
}
diff --git a/src/Item.cpp b/src/Item.cpp
index d6e8b224a..56ceae0b7 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -1,4 +1,4 @@
-
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Item.h"
--
cgit v1.2.3
From 2dd7a0373be83ab917c3c115af519b42ce30e2a9 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 24 Jun 2014 16:19:22 +0200
Subject: Better combining.
---
src/Entities/Pickup.cpp | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 88d961106..6cab79b91 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -41,12 +41,29 @@ public:
cItem & Item = ((cPickup *)a_Entity)->GetItem();
if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()))
{
- if ((Item.m_ItemCount + m_Pickup->GetItem().m_ItemCount) <= Item.GetMaxStackSize())
+ char CombineCount = Item.m_ItemCount;
+ if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize())
+ {
+ CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount;
+ }
+
+ if (CombineCount <= 0)
+ {
+ return false;
+ }
+
+ m_Pickup->GetItem().AddCount(CombineCount);
+ Item.m_ItemCount -= CombineCount;
+
+ if (Item.m_ItemCount <= 0)
{
- m_Pickup->GetItem().AddCount(Item.m_ItemCount);
a_Entity->Destroy();
- m_FoundMatchingPickup = true;
}
+ else
+ {
+ a_Entity->GetWorld()->BroadcastEntityMetadata(*a_Entity);
+ }
+ m_FoundMatchingPickup = true;
}
return false;
}
--
cgit v1.2.3
From dbcb7f819fc900164d644a1932d0cdc78b707ae0 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 24 Jun 2014 17:50:38 +0200
Subject: Optimize combining.
---
src/Entities/Pickup.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 6cab79b91..44a65412f 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -30,7 +30,7 @@ public:
virtual bool Item(cEntity * a_Entity) override
{
- if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() == m_Pickup->GetUniqueID()) || a_Entity->IsDestroyed())
+ if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() <= m_Pickup->GetUniqueID()) || a_Entity->IsDestroyed())
{
return false;
}
@@ -150,7 +150,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
}
}
- if (!IsDestroyed()) // Don't try to combine if someone has tried to combine me
+ if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't try to combine if someone has tried to combine me
{
cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
@@ -227,7 +227,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
m_World->BroadcastCollectPickup(*this, *a_Dest);
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
- if (m_Item.m_ItemCount == 0)
+ if (m_Item.m_ItemCount <= 0)
{
// All of the pickup has been collected, schedule the pickup for destroying
m_bCollected = true;
--
cgit v1.2.3
From e9aecfdf112601377ab6f640b77cb49c5a3a45bb Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Wed, 25 Jun 2014 08:07:06 +0200
Subject: BlockInfo is now a proper C++ singleton.
It is properly initialized before it is ever used.
---
src/BlockInfo.cpp | 732 +++++++++++++++++++++++++++---------------------------
src/BlockInfo.h | 23 +-
2 files changed, 374 insertions(+), 381 deletions(-)
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index b084d0915..26525e264 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -8,13 +8,6 @@
-cBlockInfo cBlockInfo::ms_Info[256];
-static bool g_IsBlockInfoInitialized = false;
-
-
-
-
-
cBlockInfo::cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
@@ -42,12 +35,17 @@ cBlockInfo::~cBlockInfo()
+/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
+It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
+It works only if it is called for the first time before the app spawns other threads. */
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
{
- if (!g_IsBlockInfoInitialized)
+ static cBlockInfo ms_Info[256];
+ static bool IsBlockInfoInitialized = false;
+ if (!IsBlockInfoInitialized)
{
- cBlockInfo::Initialize();
- g_IsBlockInfoInitialized = true;
+ cBlockInfo::Initialize(ms_Info);
+ IsBlockInfoInitialized = true;
}
return ms_Info[a_Type];
}
@@ -56,399 +54,399 @@ cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
-void cBlockInfo::Initialize(void)
+void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
{
for (unsigned int i = 0; i < 256; ++i)
{
- if (ms_Info[i].m_Handler == NULL)
+ if (a_Info[i].m_Handler == NULL)
{
- ms_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
+ a_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i);
}
}
// Emissive blocks
- ms_Info[E_BLOCK_FIRE ].m_LightValue = 15;
- ms_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
- ms_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
- ms_Info[E_BLOCK_LAVA ].m_LightValue = 15;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
- ms_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
- ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
- ms_Info[E_BLOCK_TORCH ].m_LightValue = 14;
- ms_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
- ms_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
- ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
- ms_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
- ms_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
+ a_Info[E_BLOCK_FIRE ].m_LightValue = 15;
+ a_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
+ a_Info[E_BLOCK_LAVA ].m_LightValue = 15;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
+ a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
+ a_Info[E_BLOCK_TORCH ].m_LightValue = 14;
+ a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
+ a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
// Spread blocks
- ms_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
- ms_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
// Light in water and lava dissapears faster:
- ms_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
- ms_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_SpreadLightFalloff = 3;
+ a_Info[E_BLOCK_WATER ].m_SpreadLightFalloff = 3;
// Transparent blocks
- ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_AIR ].m_Transparent = true;
- ms_Info[E_BLOCK_ANVIL ].m_Transparent = true;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
- ms_Info[E_BLOCK_CAKE ].m_Transparent = true;
- ms_Info[E_BLOCK_CARROTS ].m_Transparent = true;
- ms_Info[E_BLOCK_CHEST ].m_Transparent = true;
- ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
- ms_Info[E_BLOCK_COBWEB ].m_Transparent = true;
- ms_Info[E_BLOCK_CROPS ].m_Transparent = true;
- ms_Info[E_BLOCK_DANDELION ].m_Transparent = true;
- ms_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
- ms_Info[E_BLOCK_FENCE ].m_Transparent = true;
- ms_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
- ms_Info[E_BLOCK_FIRE ].m_Transparent = true;
- ms_Info[E_BLOCK_FLOWER ].m_Transparent = true;
- ms_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
- ms_Info[E_BLOCK_GLASS ].m_Transparent = true;
- ms_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
- ms_Info[E_BLOCK_HEAD ].m_Transparent = true;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
- ms_Info[E_BLOCK_ICE ].m_Transparent = true;
- ms_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
- ms_Info[E_BLOCK_LADDER ].m_Transparent = true;
- ms_Info[E_BLOCK_LAVA ].m_Transparent = true;
- ms_Info[E_BLOCK_LEAVES ].m_Transparent = true;
- ms_Info[E_BLOCK_LEVER ].m_Transparent = true;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
- ms_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
- ms_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
- ms_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
- ms_Info[E_BLOCK_POTATOES ].m_Transparent = true;
- ms_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
- ms_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
- ms_Info[E_BLOCK_RAIL ].m_Transparent = true;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
- ms_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
- ms_Info[E_BLOCK_SNOW ].m_Transparent = true;
- ms_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
- ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
- ms_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
- ms_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
- ms_Info[E_BLOCK_TORCH ].m_Transparent = true;
- ms_Info[E_BLOCK_VINES ].m_Transparent = true;
- ms_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
- ms_Info[E_BLOCK_WATER ].m_Transparent = true;
- ms_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
- ms_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
- ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_AIR ].m_Transparent = true;
+ a_Info[E_BLOCK_ANVIL ].m_Transparent = true;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
+ a_Info[E_BLOCK_CAKE ].m_Transparent = true;
+ a_Info[E_BLOCK_CARROTS ].m_Transparent = true;
+ a_Info[E_BLOCK_CHEST ].m_Transparent = true;
+ a_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
+ a_Info[E_BLOCK_COBWEB ].m_Transparent = true;
+ a_Info[E_BLOCK_CROPS ].m_Transparent = true;
+ a_Info[E_BLOCK_DANDELION ].m_Transparent = true;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
+ a_Info[E_BLOCK_FENCE ].m_Transparent = true;
+ a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
+ a_Info[E_BLOCK_FIRE ].m_Transparent = true;
+ a_Info[E_BLOCK_FLOWER ].m_Transparent = true;
+ a_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
+ a_Info[E_BLOCK_GLASS ].m_Transparent = true;
+ a_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
+ a_Info[E_BLOCK_HEAD ].m_Transparent = true;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_ICE ].m_Transparent = true;
+ a_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
+ a_Info[E_BLOCK_LADDER ].m_Transparent = true;
+ a_Info[E_BLOCK_LAVA ].m_Transparent = true;
+ a_Info[E_BLOCK_LEAVES ].m_Transparent = true;
+ a_Info[E_BLOCK_LEVER ].m_Transparent = true;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
+ a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
+ a_Info[E_BLOCK_POTATOES ].m_Transparent = true;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
+ a_Info[E_BLOCK_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
+ a_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
+ a_Info[E_BLOCK_SNOW ].m_Transparent = true;
+ a_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
+ a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
+ a_Info[E_BLOCK_TORCH ].m_Transparent = true;
+ a_Info[E_BLOCK_VINES ].m_Transparent = true;
+ a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
+ a_Info[E_BLOCK_WATER ].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
// TODO: Any other transparent blocks?
// One hit break blocks:
- ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
- ms_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
- ms_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
- ms_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
- ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
- ms_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
- ms_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true;
- ms_Info[E_BLOCK_REEDS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_SAPLING ].m_OneHitDig = true;
- ms_Info[E_BLOCK_TNT ].m_OneHitDig = true;
- ms_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
- ms_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_OneHitDig = true;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_OneHitDig = true;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
+ a_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
+ a_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
+ a_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
+ a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_OneHitDig = true;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_OneHitDig = true;
+ a_Info[E_BLOCK_REEDS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_SAPLING ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TNT ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
// Blocks that break when pushed by piston:
- ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_AIR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_BED ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_CAKE ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_HEAD ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
- ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
- ms_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
- ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_AIR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_BED ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CAKE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_HEAD ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
// Blocks that cannot be snowed over:
- ms_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false;
- ms_Info[E_BLOCK_AIR ].m_IsSnowable = false;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false;
- ms_Info[E_BLOCK_CACTUS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_CHEST ].m_IsSnowable = false;
- ms_Info[E_BLOCK_CROPS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_DANDELION ].m_IsSnowable = false;
- ms_Info[E_BLOCK_FIRE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_FLOWER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_GLASS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_ICE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false;
- ms_Info[E_BLOCK_LAVA ].m_IsSnowable = false;
- ms_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false;
- ms_Info[E_BLOCK_REEDS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_SAPLING ].m_IsSnowable = false;
- ms_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false;
- ms_Info[E_BLOCK_SNOW ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
- ms_Info[E_BLOCK_TNT ].m_IsSnowable = false;
- ms_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
- ms_Info[E_BLOCK_VINES ].m_IsSnowable = false;
- ms_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
- ms_Info[E_BLOCK_WATER ].m_IsSnowable = false;
- ms_Info[E_BLOCK_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false;
- ms_Info[E_BLOCK_COBWEB ].m_IsSnowable = false;
- ms_Info[E_BLOCK_HEAD ].m_IsSnowable = false;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false;
+ a_Info[E_BLOCK_AIR ].m_IsSnowable = false;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false;
+ a_Info[E_BLOCK_CACTUS ].m_IsSnowable = false;
+ a_Info[E_BLOCK_CHEST ].m_IsSnowable = false;
+ a_Info[E_BLOCK_CROPS ].m_IsSnowable = false;
+ a_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false;
+ a_Info[E_BLOCK_DANDELION ].m_IsSnowable = false;
+ a_Info[E_BLOCK_FIRE ].m_IsSnowable = false;
+ a_Info[E_BLOCK_FLOWER ].m_IsSnowable = false;
+ a_Info[E_BLOCK_GLASS ].m_IsSnowable = false;
+ a_Info[E_BLOCK_ICE ].m_IsSnowable = false;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false;
+ a_Info[E_BLOCK_LAVA ].m_IsSnowable = false;
+ a_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false;
+ a_Info[E_BLOCK_REEDS ].m_IsSnowable = false;
+ a_Info[E_BLOCK_SAPLING ].m_IsSnowable = false;
+ a_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false;
+ a_Info[E_BLOCK_SNOW ].m_IsSnowable = false;
+ a_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false;
+ a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false;
+ a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
+ a_Info[E_BLOCK_TNT ].m_IsSnowable = false;
+ a_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
+ a_Info[E_BLOCK_VINES ].m_IsSnowable = false;
+ a_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
+ a_Info[E_BLOCK_WATER ].m_IsSnowable = false;
+ a_Info[E_BLOCK_RAIL ].m_IsSnowable = false;
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false;
+ a_Info[E_BLOCK_COBWEB ].m_IsSnowable = false;
+ a_Info[E_BLOCK_HEAD ].m_IsSnowable = false;
// Blocks that don't drop without a special tool:
- ms_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true;
- ms_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_BRICK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_CAULDRON ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_COAL_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_COBBLESTONE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_COBBLESTONE_WALL ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_COBWEB ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_DIAMOND_BLOCK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_DIAMOND_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_EMERALD_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_END_STONE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_GOLD_BLOCK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_GOLD_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_IRON_BLOCK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_NETHER_BRICK ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_OBSIDIAN ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_REDSTONE_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_SANDSTONE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_SNOW ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_STONE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_STONE_BRICKS ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true;
// Nonsolid blocks:
- ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_AIR ].m_IsSolid = false;
- ms_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
- ms_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
- ms_Info[E_BLOCK_CAKE ].m_IsSolid = false;
- ms_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
- ms_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
- ms_Info[E_BLOCK_CROPS ].m_IsSolid = false;
- ms_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
- ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
- ms_Info[E_BLOCK_FENCE ].m_IsSolid = false;
- ms_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false;
- ms_Info[E_BLOCK_FIRE ].m_IsSolid = false;
- ms_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
- ms_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_LAVA ].m_IsSolid = false;
- ms_Info[E_BLOCK_LEVER ].m_IsSolid = false;
- ms_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
- ms_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
- ms_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false;
- ms_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
- ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_RAIL ].m_IsSolid = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
- ms_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
- ms_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
- ms_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
- ms_Info[E_BLOCK_REEDS ].m_IsSolid = false;
- ms_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
- ms_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
- ms_Info[E_BLOCK_SNOW ].m_IsSolid = false;
- ms_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
- ms_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
- ms_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
- ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
- ms_Info[E_BLOCK_TORCH ].m_IsSolid = false;
- ms_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false;
- ms_Info[E_BLOCK_VINES ].m_IsSolid = false;
- ms_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false;
- ms_Info[E_BLOCK_WATER ].m_IsSolid = false;
- ms_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
- ms_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
- ms_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_AIR ].m_IsSolid = false;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
+ a_Info[E_BLOCK_CAKE ].m_IsSolid = false;
+ a_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
+ a_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
+ a_Info[E_BLOCK_CROPS ].m_IsSolid = false;
+ a_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
+ a_Info[E_BLOCK_FENCE ].m_IsSolid = false;
+ a_Info[E_BLOCK_FENCE_GATE ].m_IsSolid = false;
+ a_Info[E_BLOCK_FIRE ].m_IsSolid = false;
+ a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_LAVA ].m_IsSolid = false;
+ a_Info[E_BLOCK_LEVER ].m_IsSolid = false;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
+ a_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false;
+ a_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
+ a_Info[E_BLOCK_REEDS ].m_IsSolid = false;
+ a_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
+ a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
+ a_Info[E_BLOCK_SNOW ].m_IsSolid = false;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
+ a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
+ a_Info[E_BLOCK_TORCH ].m_IsSolid = false;
+ a_Info[E_BLOCK_TRIPWIRE ].m_IsSolid = false;
+ a_Info[E_BLOCK_VINES ].m_IsSolid = false;
+ a_Info[E_BLOCK_WALLSIGN ].m_IsSolid = false;
+ a_Info[E_BLOCK_WATER ].m_IsSolid = false;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:
- ms_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
- ms_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NEW_LOG ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BEDROCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BLOCK_OF_COAL ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BOOKCASE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_BRICK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_CLAY ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_COAL_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_COBBLESTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_COMMAND_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_CRAFTING_TABLE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DIAMOND_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DIAMOND_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DIRT ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DISPENSER ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_DROPPER ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_EMERALD_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_EMERALD_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_END_STONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_FURNACE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GLOWSTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GOLD_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GOLD_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GRASS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_GRAVEL ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HARDENED_CLAY ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HAY_BALE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_ICE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_IRON_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_IRON_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_JUKEBOX ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_LAPIS_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_LAPIS_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_LOG ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_MELON ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_MYCELIUM ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NETHERRACK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NETHER_BRICK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_NOTE_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_OBSIDIAN ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_PACKED_ICE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_PLANKS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_PUMPKIN ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_QUARTZ_BLOCK ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_ORE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SANDSTONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SAND ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
}
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index 40c1db867..d6d4e7430 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -16,18 +16,8 @@ class cBlockHandler;
class cBlockInfo
{
public:
- // tolua_end
-
- cBlockInfo();
-
- ~cBlockInfo();
-
- /** (Re-)Initializes the internal BlockInfo structures. */
- static void Initialize(void);
- // tolua_begin
-
- /** Returns the associated BlockInfo structure. */
+ /** Returns the associated BlockInfo structure for the specified block type. */
static cBlockInfo & Get(BLOCKTYPE a_Type);
@@ -79,13 +69,18 @@ public:
inline static cBlockHandler * GetHandler (BLOCKTYPE a_Type) { return Get(a_Type).m_Handler; }
-
protected:
+ /** Storage for all the BlockInfo structures. */
+ typedef cBlockInfo cBlockInfoArray[256];
- // TODO xdot: Change to std::vector to support dynamic block IDs
- static cBlockInfo ms_Info[256];
+ /** Creates a default BlockInfo structure, initializes all values to their defaults */
+ cBlockInfo();
+ /** Cleans up the stored values */
+ ~cBlockInfo();
+ /** Initializes the specified BlockInfo structures with block-specific values. */
+ static void Initialize(cBlockInfoArray & a_BlockInfos);
}; // tolua_export
--
cgit v1.2.3
From f96955496f4e53105b045fb7f3fa7d34ed82b147 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Thu, 26 Jun 2014 15:56:03 +0200
Subject: GameMode check
---
src/Entities/ArrowEntity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index e46d21515..6d74b387a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -134,7 +134,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest)
{
if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest))
{
- if (m_PickupState == psInSurvivalOrCreative)
+ if (!a_Dest->IsGameModeCreative())
{
int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
if (NumAdded == 0)
--
cgit v1.2.3
From cba273dc7e381c00b214fa0806679170f4e4e2f3 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Thu, 26 Jun 2014 17:20:48 +0200
Subject: Fixed a comment and changed CombineCount to short.
---
src/Entities/Pickup.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 44a65412f..969461a6a 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -41,7 +41,7 @@ public:
cItem & Item = ((cPickup *)a_Entity)->GetItem();
if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()))
{
- char CombineCount = Item.m_ItemCount;
+ short CombineCount = Item.m_ItemCount;
if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize())
{
CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount;
@@ -150,7 +150,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
}
}
- if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't try to combine if someone has tried to combine me
+ if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup
{
cPickupCombiningCallback PickupCombiningCallback(GetPosition(), this);
m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries
--
cgit v1.2.3
From bf3229867bc6a7d531fcb43c6519a951b043a732 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Thu, 26 Jun 2014 17:26:47 +0200
Subject: Add comment.
---
src/Entities/ArrowEntity.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 6d74b387a..712ae3879 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -134,6 +134,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest)
{
if (m_IsInGround && !m_bIsCollected && CanPickup(*a_Dest))
{
+ // The arrow won't added to the inventory, when the player is creative
if (!a_Dest->IsGameModeCreative())
{
int NumAdded = a_Dest->GetInventory().AddItem(E_ITEM_ARROW);
--
cgit v1.2.3
From b90b0a1dffff366df639f49445afb43ae1a8a73c Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Thu, 26 Jun 2014 17:51:19 +0200
Subject: FurnaceRecipe parser: Added an else branch, changed to a switch.
---
src/FurnaceRecipe.cpp | 114 ++++++++++++++++++++++++++++++--------------------
1 file changed, 69 insertions(+), 45 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index 92b52c6e8..f8949d45f 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -68,64 +68,88 @@ void cFurnaceRecipe::ReloadRecipes(void)
while (std::getline(f, ParsingLine))
{
Line++;
- ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove whitespace
+ TrimString(ParsingLine);
if (ParsingLine.empty())
{
continue;
}
- // Comments
- if (ParsingLine[0] == '#')
+ switch (ParsingLine[0])
{
- continue;
- }
-
- if (ParsingLine[0] == '!') // Fuels start with a bang :)
- {
- int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
- AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
-
- if (
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
- !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
- !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value
- )
+ case '#':
{
- return;
+ // Comment
+ break;
}
- // Add to fuel list
- Fuel F;
- F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
- F.BurnTime = IBurnTime;
- m_pState->Fuel.push_back(F);
- continue;
- }
- else if (isdigit(ParsingLine[0])) // Recipes start with a numeral :)
- {
- int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
- int OItemID = 0, OItemCount = 0, OItemHealth = 0;
- AString::size_type BeginPos = 0; // Begin at start of line
-
- if (
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
- !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
- !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID
- !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
+ case '!':
+ {
+ // Fuel
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value
)
+ {
+ return;
+ }
+
+ // Add to fuel list:
+ Fuel F;
+ F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ F.BurnTime = IBurnTime;
+ m_pState->Fuel.push_back(F);
+ break;
+ }
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
{
- return;
+ // Recipe
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ int OItemID = 0, OItemCount = 0, OItemHealth = 0;
+ AString::size_type BeginPos = 0; // Begin at start of line
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time
+ !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID
+ !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
+ )
+ {
+ return;
+ }
+
+ // Add to recipe list
+ Recipe R;
+ R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth);
+ R.CookTime = IBurnTime;
+ m_pState->Recipes.push_back(R);
+ break;
}
- // Add to recipe list
- Recipe R;
- R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
- R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth);
- R.CookTime = IBurnTime;
- m_pState->Recipes.push_back(R);
- }
- }
+ default:
+ {
+ LOGWARNING("Error in furnace recipes at line %d: Unexpected text: \"%s\". Ignoring line.",
+ Line, ParsingLine.c_str()
+ );
+ break;
+ }
+ } // switch (ParsingLine[0])
+ } // while (getline(ParsingLine))
LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
}
--
cgit v1.2.3
From 67e3c645d3a648ebd4d797019a993ed9c27cdb5e Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Thu, 26 Jun 2014 17:52:37 +0200
Subject: FurnaceRecipe parser: Made the parser more forgiving.
Errors don't cause a stop in the parsing, but rather just skip the offending line.
---
src/FurnaceRecipe.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index f8949d45f..eff09a8d3 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -94,7 +94,7 @@ void cFurnaceRecipe::ReloadRecipes(void)
!ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value
)
{
- return;
+ break;
}
// Add to fuel list:
@@ -129,7 +129,7 @@ void cFurnaceRecipe::ReloadRecipes(void)
!ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
)
{
- return;
+ break;
}
// Add to recipe list
--
cgit v1.2.3
From 55bbdfa5d44a4bf7e66aa256ceba9ded3d2682dd Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Thu, 26 Jun 2014 18:18:41 +0200
Subject: FurnaceRecipe: Moved the parsing into separate functions for clarity.
---
src/FurnaceRecipe.cpp | 120 +++++++++++++++++++++++++-------------------------
src/FurnaceRecipe.h | 8 ++++
2 files changed, 68 insertions(+), 60 deletions(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index eff09a8d3..cc4098607 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -58,16 +58,16 @@ void cFurnaceRecipe::ReloadRecipes(void)
std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in);
if (!f.good())
{
- LOG("Could not open the furnace recipes file \"%s\"", FURNACE_RECIPE_FILE);
+ LOG("Could not open the furnace recipes file \"%s\". No furnace recipes are available.", FURNACE_RECIPE_FILE);
return;
}
- unsigned int Line = 0;
+ unsigned int LineNum = 0;
AString ParsingLine;
while (std::getline(f, ParsingLine))
{
- Line++;
+ LineNum++;
TrimString(ParsingLine);
if (ParsingLine.empty())
{
@@ -84,68 +84,13 @@ void cFurnaceRecipe::ReloadRecipes(void)
case '!':
{
- // Fuel
- int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
- AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
-
- if (
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
- !ReadOptionalNumbers(BeginPos, ":", "=", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
- !ReadMandatoryNumber(BeginPos, "0123456789", ParsingLine, Line, IBurnTime, true) // Read item burn time - last value
- )
- {
- break;
- }
-
- // Add to fuel list:
- Fuel F;
- F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
- F.BurnTime = IBurnTime;
- m_pState->Fuel.push_back(F);
- break;
- }
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- // Recipe
- int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
- int OItemID = 0, OItemCount = 0, OItemHealth = 0;
- AString::size_type BeginPos = 0; // Begin at start of line
-
- if (
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, IItemID) || // Read item ID
- !ReadOptionalNumbers(BeginPos, ":", "@", ParsingLine, Line, IItemCount, IItemHealth) || // Read item count (and optionally health)
- !ReadMandatoryNumber(BeginPos, "=", ParsingLine, Line, IBurnTime) || // Read item burn time
- !ReadMandatoryNumber(BeginPos, ":", ParsingLine, Line, OItemID) || // Read result ID
- !ReadOptionalNumbers(BeginPos, ":", "012456789", ParsingLine, Line, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
- )
- {
- break;
- }
-
- // Add to recipe list
- Recipe R;
- R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
- R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth);
- R.CookTime = IBurnTime;
- m_pState->Recipes.push_back(R);
+ AddFuelFromLine(ParsingLine, LineNum);
break;
}
default:
{
- LOGWARNING("Error in furnace recipes at line %d: Unexpected text: \"%s\". Ignoring line.",
- Line, ParsingLine.c_str()
- );
+ AddRecipeFromLine(ParsingLine, LineNum);
break;
}
} // switch (ParsingLine[0])
@@ -158,6 +103,61 @@ void cFurnaceRecipe::ReloadRecipes(void)
+void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, int a_LineNum)
+{
+ // Fuel
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "=", a_Line, a_LineNum, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "0123456789", a_Line, a_LineNum, IBurnTime, true) // Read item burn time - last value
+ )
+ {
+ return;
+ }
+
+ // Add to fuel list:
+ Fuel F;
+ F.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ F.BurnTime = IBurnTime;
+ m_pState->Fuel.push_back(F);
+}
+
+
+
+
+
+void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, int a_LineNum)
+{
+ int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
+ int OItemID = 0, OItemCount = 0, OItemHealth = 0;
+ AString::size_type BeginPos = 0; // Begin at start of line
+
+ if (
+ !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID
+ !ReadOptionalNumbers(BeginPos, ":", "@", a_Line, a_LineNum, IItemCount, IItemHealth) || // Read item count (and optionally health)
+ !ReadMandatoryNumber(BeginPos, "=", a_Line, a_LineNum, IBurnTime) || // Read item burn time
+ !ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, OItemID) || // Read result ID
+ !ReadOptionalNumbers(BeginPos, ":", "012456789", a_Line, a_LineNum, OItemCount, OItemHealth, true) // Read result count (and optionally health) - last value
+ )
+ {
+ return;
+ }
+
+ // Add to recipe list
+ Recipe R;
+ R.In = new cItem((ENUM_ITEM_ID)IItemID, (char)IItemCount, (short)IItemHealth);
+ R.Out = new cItem((ENUM_ITEM_ID)OItemID, (char)OItemCount, (short)OItemHealth);
+ R.CookTime = IBurnTime;
+ m_pState->Recipes.push_back(R);
+}
+
+
+
+
+
void cFurnaceRecipe::PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing)
{
LOGWARN("Error parsing furnace recipes at line %i pos " SIZE_T_FMT ": missing '%s'", a_Line, a_Position, a_CharactersMissing.c_str());
diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h
index ab78b6051..77ed35a57 100644
--- a/src/FurnaceRecipe.h
+++ b/src/FurnaceRecipe.h
@@ -41,6 +41,14 @@ public:
private:
void ClearRecipes(void);
+ /** Parses the fuel contained in the line, adds it to m_pState's fuels.
+ Logs a warning to the console on input error. */
+ void AddFuelFromLine(const AString & a_Line, int a_LineNum);
+
+ /** Parses the recipe contained in the line, adds it to m_pState's recipes.
+ Logs a warning to the console on input error. */
+ void AddRecipeFromLine(const AString & a_Line, int a_LineNum);
+
/** Calls LOGWARN with the line, position, and error */
static void PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing);
--
cgit v1.2.3
From ec1015112c969798bae3efe87998c17d130b271a Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Thu, 26 Jun 2014 18:20:12 +0200
Subject: Fixed misformed trimming.
---
src/FurnaceRecipe.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index cc4098607..412402cbc 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -68,7 +68,7 @@ void cFurnaceRecipe::ReloadRecipes(void)
while (std::getline(f, ParsingLine))
{
LineNum++;
- TrimString(ParsingLine);
+ ParsingLine = TrimString(ParsingLine);
if (ParsingLine.empty())
{
continue;
--
cgit v1.2.3
From 0df644c9f7775862c6c359b238e3440536092e04 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Thu, 26 Jun 2014 18:28:10 +0200
Subject: FurnaceRecipe parsing: Fixed whitespace removing.
---
src/FurnaceRecipe.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index 412402cbc..8add9610c 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -68,7 +68,7 @@ void cFurnaceRecipe::ReloadRecipes(void)
while (std::getline(f, ParsingLine))
{
LineNum++;
- ParsingLine = TrimString(ParsingLine);
+ ParsingLine.erase(std::remove_if(ParsingLine.begin(), ParsingLine.end(), isspace), ParsingLine.end()); // Remove ALL whitespace from the line
if (ParsingLine.empty())
{
continue;
--
cgit v1.2.3
From b832a202ab052b0544ca26225c4fe771cf31ede7 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Thu, 26 Jun 2014 18:30:02 +0100
Subject: Add Null check to SendBlockTo
Fixes CID 43611
---
src/ChunkMap.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index d2ccca94e..f0222c0f5 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1530,7 +1530,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player)
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ);
- if (Chunk->IsValid())
+ if (Chunk != NULL && Chunk->IsValid())
{
Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle());
}
--
cgit v1.2.3
From 25a0264cc46d97f52bd836280fa5d2908846ac02 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Thu, 26 Jun 2014 19:04:56 +0100
Subject: Check GridSize for 0
Fixes CID 68226 and CID 66437
---
src/Generating/GridStructGen.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp
index 95f8c38bc..a3578de6f 100644
--- a/src/Generating/GridStructGen.cpp
+++ b/src/Generating/GridStructGen.cpp
@@ -53,6 +53,16 @@ cGridStructGen::cGridStructGen(
m_MaxStructureSizeZ(a_MaxStructureSizeZ),
m_MaxCacheSize(a_MaxCacheSize)
{
+ if (m_GridSizeX == 0)
+ {
+ LOG("Grid Size cannot be zero, setting to 1");
+ m_GridSizeX = 1;
+ }
+ if (m_GridSizeZ == 0)
+ {
+ LOG("Grid Size cannot be zero, setting to 1");
+ m_GridSizeZ = 1;
+ }
size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1));
if (NumStructuresPerQuery > m_MaxCacheSize)
{
--
cgit v1.2.3
From f68dc6210fe9b5f84c1f9fb3e57fc6285d71856c Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 27 Jun 2014 09:24:11 +0200
Subject: Moved CodeCoverage into a separate cmake condition.
---
SetFlags.cmake | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 6e2417a51..b01643f4e 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -26,10 +26,14 @@ endmacro()
macro(set_flags)
- # Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
- if (NOT MSVC)
+ # Add coverage processing, if requested:
+ if (BUILD_WITH_COVERAGE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
+ endif()
+
+ # Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
+ if (NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -D_DEBUG")
--
cgit v1.2.3
From 78442edf1d1c10e473741497d17342e7e330a964 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 27 Jun 2014 11:02:28 +0200
Subject: CMake: Added log message for coverage.
---
SetFlags.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index b01643f4e..903ae0ca8 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -28,6 +28,7 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
if (BUILD_WITH_COVERAGE)
+ message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
endif()
--
cgit v1.2.3
From 62669f64dec3f615518af56a864a72d5c18280b8 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Fri, 27 Jun 2014 10:27:02 +0100
Subject: Update SetFlags.cmake
---
SetFlags.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 903ae0ca8..3f91e3d9c 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -27,7 +27,7 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
- if (BUILD_WITH_COVERAGE)
+ if (CMAKE_BUILD_TYPE STREQUALS "COVERAGE")
message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
--
cgit v1.2.3
From 9e1829e4e6de6cf3c6686a8add8317706968bd46 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Fri, 27 Jun 2014 10:45:43 +0100
Subject: Update SetFlags.cmake
---
SetFlags.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 3f91e3d9c..0b5593b19 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -27,7 +27,7 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
- if (CMAKE_BUILD_TYPE STREQUALS "COVERAGE")
+ if (${CMAKE_BUILD_TYPE} STREQUAL "COVERAGE")
message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
--
cgit v1.2.3
From 833d3284356972b06c6f34d7b91d1360a9570c5e Mon Sep 17 00:00:00 2001
From: worktycho
Date: Fri, 27 Jun 2014 11:07:03 +0100
Subject: Added MSVC guard
---
SetFlags.cmake | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 0b5593b19..e37dcd82c 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -27,10 +27,12 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
- if (${CMAKE_BUILD_TYPE} STREQUAL "COVERAGE")
- message("Including CodeCoverage")
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
- include(CodeCoverage)
+ if (NOT MSVC)
+ if (${CMAKE_BUILD_TYPE} STREQUAL "COVERAGE")
+ message("Including CodeCoverage")
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
+ include(CodeCoverage)
+ endif()
endif()
# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
--
cgit v1.2.3
From 9c29afb300200b661e35e3de3b6f26900f43517c Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 27 Jun 2014 12:15:24 +0200
Subject: CMake: pthread is used only on Unix.
---
SetFlags.cmake | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 6e2417a51..290804fb6 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -63,12 +63,16 @@ macro(set_flags)
else()
# Let gcc / clang know that we're compiling a multi-threaded app:
- add_flags_cxx("-pthread")
+ if (UNIX)
+ add_flags_cxx("-pthread")
+ endif()
+
+ # Make CLang use C++11, otherwise MSVC2008-supported extensions don't work ("override" keyword etc.):
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++11")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
endif()
# We use a signed char (fixes #640 on RasPi)
--
cgit v1.2.3
From 563f706422554d1d8ff1121b9613ab9d34951a3b Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Fri, 27 Jun 2014 19:34:53 +0200
Subject: Removed the md5 library, obsoleted by PolarSSL.
Fixes #1130.
---
CMakeLists.txt | 1 -
lib/md5/CMakeLists.txt | 12 --
lib/md5/md5.cpp | 369 ----------------------------------------
lib/md5/md5.h | 93 ----------
src/Bindings/ManualBindings.cpp | 11 +-
src/CMakeLists.txt | 2 +-
src/ClientHandle.cpp | 22 +--
7 files changed, 16 insertions(+), 494 deletions(-)
delete mode 100644 lib/md5/CMakeLists.txt
delete mode 100644 lib/md5/md5.cpp
delete mode 100644 lib/md5/md5.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56dea1a34..422427414 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,7 +62,6 @@ add_subdirectory(lib/tolua++/)
add_subdirectory(lib/sqlite/)
add_subdirectory(lib/expat/)
add_subdirectory(lib/luaexpat/)
-add_subdirectory(lib/md5/)
# We use EXCLUDE_FROM_ALL so that only the explicit dependencies are used
diff --git a/lib/md5/CMakeLists.txt b/lib/md5/CMakeLists.txt
deleted file mode 100644
index cd9fe6320..000000000
--- a/lib/md5/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-cmake_minimum_required (VERSION 2.6)
-project (md5)
-
-include_directories ("${PROJECT_SOURCE_DIR}/../../src/")
-
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
-
-add_library(md5 ${SOURCE})
diff --git a/lib/md5/md5.cpp b/lib/md5/md5.cpp
deleted file mode 100644
index eae0fc3f2..000000000
--- a/lib/md5/md5.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/* MD5
- converted to C++ class by Frank Thilo (thilo@unix-ag.org)
- for bzflag (http://www.bzflag.org)
-
- based on:
-
- md5.h and md5.c
- reference implemantion of RFC 1321
-
- Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
-
-*/
-
-/* interface header */
-#include "md5.h"
-
-/* system implementation headers */
-#include
-
-#ifndef _WIN32
- #include
-#endif
-
-
-
-
-
-// Constants for MD5Transform routine.
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-///////////////////////////////////////////////
-
-// F, G, H and I are basic MD5 functions.
-inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {
- return x&y | ~x&z;
-}
-
-inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {
- return x&z | y&~z;
-}
-
-inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {
- return x^y^z;
-}
-
-inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {
- return y ^ (x | ~z);
-}
-
-// rotate_left rotates x left n bits.
-inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {
- return (x << n) | (x >> (32-n));
-}
-
-// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
-// Rotation is separate from addition to prevent recomputation.
-inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
- a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;
-}
-
-inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
- a = rotate_left(a + G(b,c,d) + x + ac, s) + b;
-}
-
-inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
- a = rotate_left(a + H(b,c,d) + x + ac, s) + b;
-}
-
-inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
- a = rotate_left(a + I(b,c,d) + x + ac, s) + b;
-}
-
-//////////////////////////////////////////////
-
-// default ctor, just initailize
-MD5::MD5()
-{
- init();
-}
-
-//////////////////////////////////////////////
-
-// nifty shortcut ctor, compute MD5 for string and finalize it right away
-MD5::MD5(const std::string &text)
-{
- init();
- update(text.c_str(), text.length());
- finalize();
-}
-
-//////////////////////////////
-
-void MD5::init()
-{
- finalized=false;
-
- count[0] = 0;
- count[1] = 0;
-
- // load magic initialization constants.
- state[0] = 0x67452301;
- state[1] = 0xefcdab89;
- state[2] = 0x98badcfe;
- state[3] = 0x10325476;
-}
-
-//////////////////////////////
-
-// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
-void MD5::decode(uint4 output[], const uint1 input[], size_type len)
-{
- for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
- (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
-}
-
-//////////////////////////////
-
-// encodes input (uint4) into output (unsigned char). Assumes len is
-// a multiple of 4.
-void MD5::encode(uint1 output[], const uint4 input[], size_type len)
-{
- for (size_type i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = input[i] & 0xff;
- output[j+1] = (input[i] >> 8) & 0xff;
- output[j+2] = (input[i] >> 16) & 0xff;
- output[j+3] = (input[i] >> 24) & 0xff;
- }
-}
-
-//////////////////////////////
-
-// apply MD5 algo on a block
-void MD5::transform(const uint1 block[blocksize])
-{
- uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
- decode (x, block, blocksize);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- // Zeroize sensitive information.
- memset(x, 0, sizeof x);
-}
-
-//////////////////////////////
-
-// MD5 block update operation. Continues an MD5 message-digest
-// operation, processing another message block
-void MD5::update(const unsigned char input[], size_type length)
-{
- // compute number of bytes mod 64
- size_type index = count[0] / 8 % blocksize;
-
- // Update number of bits
- if ((count[0] += (length << 3)) < (length << 3))
- count[1]++;
- count[1] += (length >> 29);
-
- // number of bytes we need to fill in buffer
- size_type firstpart = 64 - index;
-
- size_type i;
-
- // transform as many times as possible.
- if (length >= firstpart)
- {
- // fill buffer first, transform
- memcpy(&buffer[index], input, firstpart);
- transform(buffer);
-
- // transform chunks of blocksize (64 bytes)
- for (i = firstpart; i + blocksize <= length; i += blocksize)
- transform(&input[i]);
-
- index = 0;
- }
- else
- i = 0;
-
- // buffer remaining input
- memcpy(&buffer[index], &input[i], length-i);
-}
-
-//////////////////////////////
-
-// for convenience provide a verson with signed char
-void MD5::update(const char input[], size_type length)
-{
- update((const unsigned char*)input, length);
-}
-
-//////////////////////////////
-
-// MD5 finalization. Ends an MD5 message-digest operation, writing the
-// the message digest and zeroizing the context.
-MD5& MD5::finalize()
-{
- static unsigned char padding[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
- if (!finalized) {
- // Save number of bits
- unsigned char bits[8];
- encode(bits, count, 8);
-
- // pad out to 56 mod 64.
- size_type index = count[0] / 8 % 64;
- size_type padLen = (index < 56) ? (56 - index) : (120 - index);
- update(padding, padLen);
-
- // Append length (before padding)
- update(bits, 8);
-
- // Store state in digest
- encode(digest, state, 16);
-
- // Zeroize sensitive information.
- memset(buffer, 0, sizeof buffer);
- memset(count, 0, sizeof count);
-
- finalized=true;
- }
-
- return *this;
-}
-
-//////////////////////////////
-
-// return hex representation of digest as string
-std::string MD5::hexdigest() const
-{
- if (!finalized)
- return "";
-
- char buf[33];
- for (int i=0; i<16; i++)
- sprintf(buf+i*2, "%02x", digest[i]);
- buf[32]=0;
-
- return std::string(buf);
-}
-
-//////////////////////////////
-
-std::ostream& operator<<(std::ostream& out, MD5 md5)
-{
- return out << md5.hexdigest();
-}
-
-//////////////////////////////
-
-std::string md5(const std::string & str)
-{
- MD5 md5 = MD5(str);
-
- return md5.hexdigest();
-}
diff --git a/lib/md5/md5.h b/lib/md5/md5.h
deleted file mode 100644
index 3aa88ac22..000000000
--- a/lib/md5/md5.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* MD5
- converted to C++ class by Frank Thilo (thilo@unix-ag.org)
- for bzflag (http://www.bzflag.org)
-
- based on:
-
- md5.h and md5.c
- reference implementation of RFC 1321
-
- Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
-
-*/
-
-#ifndef BZF_MD5_H
-#define BZF_MD5_H
-
-#include
-#include
-
-
-// a small class for calculating MD5 hashes of strings or byte arrays
-// it is not meant to be fast or secure
-//
-// usage: 1) feed it blocks of uchars with update()
-// 2) finalize()
-// 3) get hexdigest() string
-// or
-// MD5(std::string).hexdigest()
-//
-// assumes that char is 8 bit and int is 32 bit
-class MD5
-{
-public:
- typedef unsigned int size_type; // must be 32bit
-
- MD5();
- MD5(const std::string& text);
- void update(const unsigned char *buf, size_type length);
- void update(const char *buf, size_type length);
- MD5& finalize();
- std::string hexdigest() const;
- friend std::ostream& operator<<(std::ostream&, MD5 md5);
-
-private:
- void init();
- typedef unsigned char uint1; // 8bit
- typedef unsigned int uint4; // 32bit
- enum {blocksize = 64}; // VC6 won't eat a const static int here
-
- void transform(const uint1 block[blocksize]);
- static void decode(uint4 output[], const uint1 input[], size_type len);
- static void encode(uint1 output[], const uint4 input[], size_type len);
-
- bool finalized;
- uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
- uint4 count[2]; // 64bit counter for number of bits (lo, hi)
- uint4 state[4]; // digest so far
- uint1 digest[16]; // the result
-
- // low level logic operations
- static inline uint4 F(uint4 x, uint4 y, uint4 z);
- static inline uint4 G(uint4 x, uint4 y, uint4 z);
- static inline uint4 H(uint4 x, uint4 y, uint4 z);
- static inline uint4 I(uint4 x, uint4 y, uint4 z);
- static inline uint4 rotate_left(uint4 x, int n);
- static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
- static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
- static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
- static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
-};
-
-std::string md5(const std::string & str);
-
-#endif
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index f52d970bf..3692851eb 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -4,7 +4,7 @@
#include "ManualBindings.h"
#undef TOLUA_TEMPLATE_BIND
#include "tolua++/include/tolua++.h"
-
+#include "polarssl\md5.h"
#include "Plugin.h"
#include "PluginLua.h"
#include "PluginManager.h"
@@ -25,7 +25,6 @@
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
-#include "md5/md5.h"
#include "../LineBlockTracer.h"
#include "../WorldStorage/SchematicFileSerializer.h"
#include "../CompositeChat.h"
@@ -2001,9 +2000,11 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
static int tolua_md5(lua_State* tolua_S)
{
- std::string SourceString = tolua_tostring(tolua_S, 1, 0);
- std::string CryptedString = md5( SourceString );
- tolua_pushstring( tolua_S, CryptedString.c_str() );
+ unsigned char Output[16];
+ size_t len = 0;
+ const unsigned char * SourceString = (const unsigned char *)lua_tolstring(tolua_S, 1, &len);
+ md5(SourceString, len, Output);
+ lua_pushlstring(tolua_S, (const char *)Output, ARRAYCOUNT(Output));
return 1;
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 335ce8315..deea92aec 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -260,4 +260,4 @@ endif ()
if (WIN32)
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)
endif()
-target_link_libraries(${EXECUTABLE} md5 luaexpat iniFile jsoncpp polarssl zlib lua sqlite)
+target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib lua sqlite)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 46083a8f1..611995148 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -30,7 +30,7 @@
#include "CompositeChat.h"
#include "Items/ItemSword.h"
-#include "md5/md5.h"
+#include "polarssl/md5.h"
@@ -239,18 +239,14 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username)
// xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B
// Generate an md5 checksum, and use it as base for the ID:
- MD5 Checksum(a_Username);
- AString UUID = Checksum.hexdigest();
- UUID[12] = '3'; // Version 3 UUID
- UUID[16] = '8'; // Variant 1 UUID
-
- // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions:
- UUID.insert(8, "-");
- UUID.insert(13, "-");
- UUID.insert(18, "-");
- UUID.insert(23, "-");
-
- return UUID;
+ unsigned char MD5[16];
+ md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5);
+ return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x",
+ MD5[0], MD5[1], MD5[2], MD5[3],
+ MD5[4], MD5[5], MD5[6], MD5[7],
+ MD5[8], MD5[9], MD5[10], MD5[11],
+ MD5[12], MD5[13], MD5[14], MD5[15]
+ );
}
--
cgit v1.2.3
From d7bc5c5bd32f8b5560403ecf6631040891fe9b9e Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Fri, 27 Jun 2014 20:23:05 +0200
Subject: Added PolarSSL dependency to Bindings.
---
src/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index deea92aec..4b78181ee 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -134,7 +134,7 @@ if (NOT MSVC)
Bindings/WebPlugin
)
- target_link_libraries(Bindings lua sqlite tolualib)
+ target_link_libraries(Bindings lua sqlite tolualib polarssl)
#clear file
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt)
--
cgit v1.2.3
From 9926abd4f55d668dec9e06c2ba23fa3bb9209eeb Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Fri, 27 Jun 2014 20:56:29 +0200
Subject: Added generic entity-collecting.
Now any cEntity can be collected, not only cPickups.
This should help PR #1098.
---
src/Chunk.cpp | 4 ++--
src/Chunk.h | 2 +-
src/ChunkMap.cpp | 6 +++---
src/ChunkMap.h | 1 +
src/ClientHandle.cpp | 4 ++--
src/ClientHandle.h | 2 +-
src/Protocol/Protocol.h | 2 +-
src/Protocol/Protocol125.cpp | 4 ++--
src/Protocol/Protocol125.h | 2 +-
src/Protocol/Protocol132.cpp | 8 ++++----
src/Protocol/Protocol132.h | 2 +-
src/Protocol/Protocol17x.cpp | 4 ++--
src/Protocol/Protocol17x.h | 2 +-
src/Protocol/ProtocolRecognizer.cpp | 4 ++--
src/Protocol/ProtocolRecognizer.h | 2 +-
src/World.cpp | 11 ++++++++++-
src/World.h | 1 +
17 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 1320d5ccd..0fee40cac 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -2701,7 +2701,7 @@ void cChunk::BroadcastChunkData(cChunkDataSerializer & a_Serializer, const cClie
-void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2709,7 +2709,7 @@ void cChunk::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_
{
continue;
}
- (*itr)->SendCollectPickup(a_Pickup, a_Player);
+ (*itr)->SendCollectEntity(a_Entity, a_Player);
} // for itr - LoadedByClient[]
}
diff --git a/src/Chunk.h b/src/Chunk.h
index 7664a7afd..e9d964e05 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -279,7 +279,7 @@ public:
void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
- void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index d2ccca94e..c9fb0b59e 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -419,16 +419,16 @@ void cChunkMap::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSeriali
-void cChunkMap::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- cChunkPtr Chunk = GetChunkNoGen(a_Pickup.GetChunkX(), ZERO_CHUNK_Y, a_Pickup.GetChunkZ());
+ cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), ZERO_CHUNK_Y, a_Entity.GetChunkZ());
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
+ Chunk->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude);
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 3ee0bab3c..433516490 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -70,6 +70,7 @@ public:
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
void BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 46083a8f1..16cfe1aec 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2077,9 +2077,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ
-void cClientHandle::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cClientHandle::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
- m_Protocol->SendCollectPickup(a_Pickup, a_Player);
+ m_Protocol->SendCollectEntity(a_Entity, a_Player);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 3e18cbdad..02bc0c719 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -123,7 +123,7 @@ public:
void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChat (const cCompositeChat & a_Message);
void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer);
- void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player);
+ void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player);
void SendDestroyEntity (const cEntity & a_Entity);
void SendDisconnect (const AString & a_Reason);
void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ);
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index c6e569919..e08a5a51b 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -64,7 +64,7 @@ public:
virtual void SendChat (const AString & a_Message) = 0;
virtual void SendChat (const cCompositeChat & a_Message) = 0;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) = 0;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0;
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
virtual void SendDisconnect (const AString & a_Reason) = 0;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+)
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 491058919..d53427bf7 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -274,11 +274,11 @@ void cProtocol125::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
-void cProtocol125::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocol125::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_COLLECT_PICKUP);
- WriteInt (a_Pickup.GetUniqueID());
+ WriteInt (a_Entity.GetUniqueID());
WriteInt (a_Player.GetUniqueID());
Flush();
}
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 85418f71f..747bf512d 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -36,7 +36,7 @@ public:
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp
index 1e3fc8de8..31cf99f53 100644
--- a/src/Protocol/Protocol132.cpp
+++ b/src/Protocol/Protocol132.cpp
@@ -188,19 +188,19 @@ void cProtocol132::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
-void cProtocol132::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocol132::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_COLLECT_PICKUP);
- WriteInt (a_Pickup.GetUniqueID());
+ WriteInt (a_Entity.GetUniqueID());
WriteInt (a_Player.GetUniqueID());
Flush();
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
SendSoundEffect(
"random.pop",
- (int)(a_Pickup.GetPosX() * 8), (int)(a_Pickup.GetPosY() * 8), (int)(a_Pickup.GetPosZ() * 8),
- 0.5, (float)(0.75 + ((float)((a_Pickup.GetUniqueID() * 23) % 32)) / 64)
+ (int)(a_Entity.GetPosX() * 8), (int)(a_Entity.GetPosY() * 8), (int)(a_Entity.GetPosZ() * 8),
+ 0.5, (float)(0.75 + ((float)((a_Entity.GetUniqueID() * 23) % 32)) / 64)
);
}
diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h
index 32bc7d581..e5d3ee80c 100644
--- a/src/Protocol/Protocol132.h
+++ b/src/Protocol/Protocol132.h
@@ -48,7 +48,7 @@ public:
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 02c577dc8..49fef0b8e 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -351,12 +351,12 @@ void cProtocol172::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
-void cProtocol172::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocol172::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
- Pkt.WriteInt(a_Pickup.GetUniqueID());
+ Pkt.WriteInt(a_Entity.GetUniqueID());
Pkt.WriteInt(a_Player.GetUniqueID());
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 8be1d9211..07c8c8459 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -68,7 +68,7 @@ public:
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 80f5da25a..2436c49c3 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -181,10 +181,10 @@ void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSe
-void cProtocolRecognizer::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
+void cProtocolRecognizer::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendCollectPickup(a_Pickup, a_Player);
+ m_Protocol->SendCollectEntity(a_Entity, a_Player);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 5e178447c..a5a6c59b6 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -71,7 +71,7 @@ public:
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
- virtual void SendCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player) override;
+ virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
virtual void SendDisconnect (const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
diff --git a/src/World.cpp b/src/World.cpp
index 5b067b386..bd7694e96 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1877,9 +1877,18 @@ void cWorld::BroadcastChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer
+void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
+{
+ m_ChunkMap->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude);
+}
+
+
+
+
+
void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastCollectPickup(a_Pickup, a_Player, a_Exclude);
+ m_ChunkMap->BroadcastCollectEntity(a_Pickup, a_Player, a_Exclude);
}
diff --git a/src/World.h b/src/World.h
index 2b7f78760..692d5a497 100644
--- a/src/World.h
+++ b/src/World.h
@@ -206,6 +206,7 @@ public:
// tolua_end
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
+ void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
--
cgit v1.2.3
From b6df30831d6b9b84bbb231dd8cfe4c1532666da4 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 27 Jun 2014 23:13:26 +0100
Subject: Fixed server forcing players afloat
* Fixes #1131
---
src/Entities/Entity.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index ee7ce06ac..2b256e766 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1090,7 +1090,10 @@ void cEntity::HandleAir(void)
if (IsSubmerged())
{
- SetSpeedY(1); // Float in the water
+ if (!IsPlayer()) // Players control themselves
+ {
+ SetSpeedY(1); // Float in the water
+ }
// Either reduce air level or damage player
if (m_AirLevel < 1)
--
cgit v1.2.3
From 69befa9851e8957d9efa996b08217287a87dee8c Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 27 Jun 2014 23:16:37 +0100
Subject: Fixed bad water/redstone simulator communication
* Fixes #713
---
src/Simulator/FloodyFluidSimulator.cpp | 54 ++++++++++++++--------------------
1 file changed, 22 insertions(+), 32 deletions(-)
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index e95af3a1c..4ffda2365 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -217,14 +217,20 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
{
ASSERT(a_NewMeta <= 8); // Invalid meta values
ASSERT(a_NewMeta > 0); // Source blocks aren't spread
-
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_NearChunk->UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta))
+
+ a_NearChunk = a_NearChunk->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
+ if ((a_NearChunk == NULL) || (!a_NearChunk->IsValid()))
{
// Chunk not available
return;
}
+
+ const int BlockX = a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX;
+ const int BlockZ = a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ;
+
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ a_NearChunk->GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta);
if (IsAllowedBlock(BlockType))
{
@@ -246,15 +252,9 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
a_RelX, a_RelY, a_RelZ,
ItemTypeToString(NewBlock).c_str()
);
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+ a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
- int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width;
- int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width;
-
- BaseX += a_RelX;
- BaseZ += a_RelZ;
-
- a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f);
+ a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f);
return;
}
}
@@ -267,15 +267,9 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s",
a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
);
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
-
- int BaseX = a_NearChunk->GetPosX() * cChunkDef::Width;
- int BaseZ = a_NearChunk->GetPosZ() * cChunkDef::Width;
-
- BaseX += a_RelX;
- BaseZ += a_RelZ;
+ a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
- a_NearChunk->BroadcastSoundEffect("random.fizz", BaseX * 8, a_RelY * 8, BaseZ * 8, 0.5f, 1.5f);
+ a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f);
return;
}
}
@@ -303,21 +297,17 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
m_World,
PluginInterface,
NULL,
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
+ BlockX,
a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ
+ BlockZ
);
}
} // if (CanWashAway)
-
+
// Spread:
- FLOG(" Spreading to {%d, %d, %d} with meta %d",
- a_NearChunk->GetPosX() * cChunkDef::Width + a_RelX,
- a_RelY,
- a_NearChunk->GetPosZ() * cChunkDef::Width + a_RelZ,
- a_NewMeta
- );
- a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
+ FLOG(" Spreading to {%d, %d, %d} with meta %d", BlockX, a_RelY, BlockZ, a_NewMeta);
+ a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
+ m_World.GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, a_NearChunk);
HardenBlock(a_NearChunk, a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
}
@@ -409,13 +399,13 @@ bool cFloodyFluidSimulator::HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY
if (a_Meta == 0)
{
// Source lava block
- a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0);
return true;
}
// Ignore last lava level
else if (a_Meta <= 4)
{
- a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0);
+ a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0);
return true;
}
}
--
cgit v1.2.3
From 0a20e19a64f88e66af68018cc46bc37dfdca7948 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 28 Jun 2014 00:29:19 +0100
Subject: Minor change to buttons and levers
+ They now detect if the block they are on occupies its voxel, instead
of just being solid
---
src/Blocks/BlockButton.h | 2 +-
src/Blocks/BlockLever.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 4b2f6f618..7d9af207d 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -102,7 +102,7 @@ public:
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
- return (a_RelY > 0) && (cBlockInfo::IsSolid(BlockIsOn));
+ return (a_RelY > 0) && (cBlockInfo::FullyOccupiesVoxel(BlockIsOn));
}
} ;
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index f1d3ff6d2..afe43abf8 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -22,7 +22,7 @@ public:
// Flip the ON bit on/off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
- a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LEVER, Meta); // SetMeta doesn't work for unpowering levers, so setblock
+ a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
@@ -104,7 +104,7 @@ public:
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
- return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn);
+ return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
}
--
cgit v1.2.3
From de543ff73fa8bb846030ffc702ed4db9f2e89f7b Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 28 Jun 2014 00:29:32 +0100
Subject: Added more block exceptions to torches
---
src/Blocks/BlockTorch.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index 8ddec8de1..44c33c429 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -154,7 +154,11 @@ public:
if (
(BlockInQuestion == E_BLOCK_GLASS) ||
+ (BlockInQuestion == E_BLOCK_STAINED_GLASS) ||
(BlockInQuestion == E_BLOCK_FENCE) ||
+ (BlockInQuestion == E_BLOCK_SOULSAND) ||
+ (BlockInQuestion == E_BLOCK_MOB_SPAWNER) ||
+ (BlockInQuestion == E_BLOCK_END_PORTAL_FRAME) || // Actual vanilla behaviour
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||
(BlockInQuestion == E_BLOCK_COBBLESTONE_WALL)
)
--
cgit v1.2.3
From 3e104c25e930eddedeb456c6cad456d7d01a38de Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Sat, 28 Jun 2014 12:49:08 +0200
Subject: Changed include folders to work for Bindings, too.
---
src/CMakeLists.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4b78181ee..dab97003e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,9 +1,9 @@
cmake_minimum_required (VERSION 2.8.2)
project (MCServer)
-include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/")
-include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/jsoncpp/include")
-include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/polarssl/include")
+include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/")
+include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include")
+include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++)
set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs)
--
cgit v1.2.3
From bef84b4821724c7119a3cb007d9e1265a56a27f0 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sat, 28 Jun 2014 12:59:09 +0200
Subject: Fix sheep color's, add shear sound.
---
src/Mobs/Monster.cpp | 2 +-
src/Mobs/Sheep.cpp | 41 ++++++++++++++++++++++++++++++++++++++++-
src/Mobs/Sheep.h | 2 +-
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 5843ca5a6..5ffd645b3 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -900,7 +900,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
case mtMooshroom: toReturn = new cMooshroom(); break;
case mtOcelot: toReturn = new cOcelot(); break;
case mtPig: toReturn = new cPig(); break;
- case mtSheep: toReturn = new cSheep (Random.NextInt(15)); break; // Colour parameter
+ case mtSheep: toReturn = new cSheep(); break;
case mtSilverfish: toReturn = new cSilverfish(); break;
case mtSnowGolem: toReturn = new cSnowGolem(); break;
case mtSpider: toReturn = new cSpider(); break;
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index 5a6b760af..cc7315a86 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -5,6 +5,7 @@
#include "../BlockID.h"
#include "../Entities/Player.h"
#include "../World.h"
+#include "FastRandom.h"
@@ -16,6 +17,43 @@ cSheep::cSheep(int a_Color) :
m_WoolColor(a_Color),
m_TimeToStopEating(-1)
{
+ // Generate random wool color.
+ if (m_WoolColor == -1)
+ {
+ cFastRandom Random;
+ int Chance = Random.NextInt(101);
+
+ if (Chance <= 81)
+ {
+ // White
+ m_WoolColor = 0;
+ }
+ else if (Chance <= 86)
+ {
+ // Black
+ m_WoolColor = 15;
+ }
+ else if (Chance <= 91)
+ {
+ // Grey
+ m_WoolColor = 7;
+ }
+ else if (Chance <= 96)
+ {
+ // Light grey
+ m_WoolColor = 8;
+ }
+ else if (Chance <= 99)
+ {
+ // Brown
+ m_WoolColor = 12;
+ }
+ else
+ {
+ // Pink
+ m_WoolColor = 6;
+ }
+ }
}
@@ -37,7 +75,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSheep::OnRightClicked(cPlayer & a_Player)
{
const cItem & EquippedItem = a_Player.GetEquippedItem();
- if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
+ if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && !IsSheared() && !IsBaby())
{
m_IsSheared = true;
m_World->BroadcastEntityMetadata(*this);
@@ -51,6 +89,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
+ m_World->BroadcastSoundEffect("mob.sheep.shear", POSX_TOINT * 8, POSY_TOINT * 8, POSZ_TOINT * 8, 1.0f, 1.0f);
}
else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
{
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 402e8e61c..14da81364 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -13,7 +13,7 @@ class cSheep :
typedef cPassiveMonster super;
public:
- cSheep(int a_Color);
+ cSheep(int a_Color = -1);
CLASS_PROTODEF(cSheep);
--
cgit v1.2.3
From 11d02a447e45e96e4652f25afc6d040597ad2064 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sat, 28 Jun 2014 13:19:32 +0200
Subject: Save IsSheared from Sheep.
---
src/Mobs/Sheep.h | 3 +++
src/WorldStorage/WSSAnvil.cpp | 15 +++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 14da81364..21dca7787 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -24,7 +24,10 @@ public:
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
bool IsSheared(void) const { return m_IsSheared; }
+ void SetSheared(bool a_IsSheared) { m_IsSheared = a_IsSheared; }
+
int GetFurColor(void) const { return m_WoolColor; }
+ void SetFurColor(bool a_WoolColor) { m_WoolColor = a_WoolColor; }
private:
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 9870c144a..5c209c7fa 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -2073,10 +2073,11 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color");
-
- if (ColorIdx < 0) { return; }
-
- int Color = (int)a_NBT.GetByte(ColorIdx);
+ int Color = -1;
+ if (ColorIdx > 0)
+ {
+ Color = (int)a_NBT.GetByte(ColorIdx);
+ }
std::auto_ptr Monster(new cSheep(Color));
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
@@ -2089,6 +2090,12 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
return;
}
+ int ShearedIdx = a_NBT.FindChildByName(a_TagIdx, "Sheared");
+ if (ShearedIdx > 0)
+ {
+ Monster.get()->SetSheared((bool)a_NBT.GetByte(ShearedIdx));
+ }
+
a_Entities.push_back(Monster.release());
}
--
cgit v1.2.3
From 48639ee4d25268525d94b2da32924164ff055d82 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Sat, 28 Jun 2014 18:16:26 +0200
Subject: CMake: Added polarssl include dir as non-system.
---
src/CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dab97003e..2f4d6ea13 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -119,7 +119,8 @@ if (NOT MSVC)
# lib dependencies are not included
-
+ include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
+
#add cpp files here
add_library(Bindings
Bindings/Bindings
--
cgit v1.2.3
From 1495bba17c04a5c756ba3a8eb3e881ef59aa1adf Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Sat, 28 Jun 2014 18:20:46 +0200
Subject: Fixed a silly path error in #include.
---
src/Bindings/ManualBindings.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 3692851eb..88d40bfd9 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -4,7 +4,7 @@
#include "ManualBindings.h"
#undef TOLUA_TEMPLATE_BIND
#include "tolua++/include/tolua++.h"
-#include "polarssl\md5.h"
+#include "polarssl/md5.h"
#include "Plugin.h"
#include "PluginLua.h"
#include "PluginManager.h"
--
cgit v1.2.3
From 61cb08b54698e9b70f629858a6a9c5b389db8b3e Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 28 Jun 2014 20:44:34 +0100
Subject: Implemented tripwire(s) (hooks)
* Fixes #944
---
src/BlockInfo.cpp | 9 ++
src/Blocks/BlockHandler.cpp | 4 +
src/Blocks/BlockStone.h | 2 -
src/Blocks/BlockTripwire.h | 32 +++++
src/Blocks/BlockTripwireHook.h | 82 +++++++++++++
src/Items/ItemHandler.cpp | 2 +
src/Items/ItemString.h | 39 ++++++
src/Simulator/IncrementalRedstoneSimulator.cpp | 163 ++++++++++++++++++++++---
src/Simulator/IncrementalRedstoneSimulator.h | 8 ++
9 files changed, 324 insertions(+), 17 deletions(-)
create mode 100644 src/Blocks/BlockTripwire.h
create mode 100644 src/Blocks/BlockTripwireHook.h
create mode 100644 src/Items/ItemString.h
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 26525e264..16314290a 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -101,6 +101,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
@@ -160,6 +162,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true;
a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
a_Info[E_BLOCK_TORCH ].m_Transparent = true;
a_Info[E_BLOCK_VINES ].m_Transparent = true;
@@ -197,6 +201,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_TNT ].m_OneHitDig = true;
a_Info[E_BLOCK_TALL_GRASS ].m_OneHitDig = true;
a_Info[E_BLOCK_TORCH ].m_OneHitDig = true;
+ a_Info[E_BLOCK_TRIPWIRE ].m_OneHitDig = true;
// Blocks that break when pushed by piston:
@@ -239,6 +244,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TRIPWIRE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_PistonBreakable = true;
a_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
a_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
@@ -280,6 +287,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
a_Info[E_BLOCK_TNT ].m_IsSnowable = false;
a_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
+ a_Info[E_BLOCK_TRIPWIRE ].m_IsSnowable = false;
+ a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_IsSnowable = false;
a_Info[E_BLOCK_VINES ].m_IsSnowable = false;
a_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
a_Info[E_BLOCK_WATER ].m_IsSnowable = false;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 405c9bf43..3ddb7531d 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -65,6 +65,8 @@
#include "BlockRedstoneRepeater.h"
#include "BlockRedstoneTorch.h"
#include "BlockTNT.h"
+#include "BlockTripwire.h"
+#include "BlockTripwireHook.h"
#include "BlockSand.h"
#include "BlockSapling.h"
#include "BlockSideways.h"
@@ -291,6 +293,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType);
case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType);
+ case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
+ case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h
index af4c6509a..cd5230f49 100644
--- a/src/Blocks/BlockStone.h
+++ b/src/Blocks/BlockStone.h
@@ -2,8 +2,6 @@
#pragma once
#include "BlockHandler.h"
-#include "../MersenneTwister.h"
-#include "../World.h"
diff --git a/src/Blocks/BlockTripwire.h b/src/Blocks/BlockTripwire.h
new file mode 100644
index 000000000..3ab17bf4a
--- /dev/null
+++ b/src/Blocks/BlockTripwire.h
@@ -0,0 +1,32 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockTripwireHandler :
+ public cBlockHandler
+{
+public:
+ cBlockTripwireHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "";
+ }
+};
+
+
+
+
diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h
new file mode 100644
index 000000000..f849fb8ad
--- /dev/null
+++ b/src/Blocks/BlockTripwireHook.h
@@ -0,0 +1,82 @@
+#pragma once
+
+#include "BlockHandler.h"
+#include "MetaRotator.h"
+
+
+
+
+
+class cBlockTripwireHookHandler :
+ public cMetaRotator
+{
+public:
+ cBlockTripwireHookHandler(BLOCKTYPE a_BlockType)
+ : cMetaRotator(a_BlockType)
+ {
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = m_BlockType;
+
+ a_BlockMeta = DirectionToMetadata(a_BlockFace);
+
+ return true;
+ }
+
+ inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction)
+ {
+ switch (a_Direction)
+ {
+ case BLOCK_FACE_XM: return 0x1;
+ case BLOCK_FACE_XP: return 0x3;
+ case BLOCK_FACE_ZM: return 0x2;
+ case BLOCK_FACE_ZP: return 0x0;
+ default: ASSERT(!"Unhandled tripwire hook direction!"); return 0x0;
+ }
+ }
+
+ inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
+ {
+ switch (a_Meta & 0x03)
+ {
+ case 0x1: return BLOCK_FACE_XM;
+ case 0x3: return BLOCK_FACE_XP;
+ case 0x2: return BLOCK_FACE_ZM;
+ case 0x0: return BLOCK_FACE_ZP;
+ default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE;
+ }
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_BLOCK_TRIPWIRE_HOOK, 1, 0));
+ }
+
+ virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
+ {
+ NIBBLETYPE Meta;
+ a_Chunk.UnboundedRelGetBlockMeta(a_RelX, a_RelY, a_RelZ, Meta);
+
+ AddFaceDirection(a_RelX, a_RelY, a_RelZ, MetadataToDirection(Meta), true);
+ BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
+
+ return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
+ }
+
+ virtual const char * GetStepSound(void) override
+ {
+ return "step.wood";
+ }
+};
+
+
+
+
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index f639423ae..a2fd4e3f8 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -44,6 +44,7 @@
#include "ItemSign.h"
#include "ItemMobHead.h"
#include "ItemSpawnEgg.h"
+#include "ItemString.h"
#include "ItemSugarcane.h"
#include "ItemSword.h"
@@ -129,6 +130,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_HEAD: return new cItemMobHeadHandler(a_ItemType);
case E_ITEM_SNOWBALL: return new cItemSnowballHandler();
case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType);
+ case E_ITEM_STRING: return new cItemStringHandler(a_ItemType);
case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType);
case E_ITEM_WOODEN_HOE:
diff --git a/src/Items/ItemString.h b/src/Items/ItemString.h
new file mode 100644
index 000000000..a97fbe0ce
--- /dev/null
+++ b/src/Items/ItemString.h
@@ -0,0 +1,39 @@
+
+#pragma once
+
+#include "ItemHandler.h"
+
+
+
+
+
+class cItemStringHandler :
+ public cItemHandler
+{
+public:
+ cItemStringHandler(int a_ItemType) :
+ cItemHandler(a_ItemType)
+ {
+ }
+
+ virtual bool IsPlaceable(void) override
+ {
+ return true;
+ }
+
+ virtual bool GetPlacementBlockTypeMeta(
+ cWorld * a_World, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+ ) override
+ {
+ a_BlockType = E_BLOCK_TRIPWIRE;
+ a_BlockMeta = 0;
+ return true;
+ }
+};
+
+
+
+
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 10446a879..866a5b65a 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "IncrementalRedstoneSimulator.h"
+#include "BoundingBox.h"
#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
@@ -12,10 +13,13 @@
#include "../Blocks/BlockButton.h"
#include "../Blocks/BlockLever.h"
#include "../Blocks/BlockPiston.h"
+#include "../Blocks/BlockTripwireHook.h"
+
+#define WAKE_SIMULATOR_IF_DIRTY(a_Chunk, a_BlockX, a_BlockY, a_BlockZ) if (a_Chunk->IsRedstoneDirty()) WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
+
-
cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulator(cWorld & a_World) :
super(a_World),
@@ -99,10 +103,11 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
// Changeable sources
((Block == E_BLOCK_REDSTONE_WIRE) && (Meta == 0)) ||
((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) ||
- ((Block == E_BLOCK_DETECTOR_RAIL) && (Meta & 0x08) == 0) ||
+ ((Block == E_BLOCK_DETECTOR_RAIL) && ((Meta & 0x08) == 0)) ||
(((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) ||
(((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) ||
- (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0))
+ (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) ||
+ ((Block == E_BLOCK_TRIPWIRE_HOOK) && ((Meta & 0x08) == 0))
)
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
@@ -289,6 +294,9 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int
switch (dataitr->Data)
{
case E_BLOCK_DAYLIGHT_SENSOR: HandleDaylightSensor(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRIPWIRE: HandleTripwire(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRIPWIRE_HOOK: HandleTripwireHook(dataitr->x, dataitr->y, dataitr->z); break;
+
case E_BLOCK_WOODEN_PRESSURE_PLATE:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
@@ -1120,7 +1128,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
case E_BLOCK_STONE_PRESSURE_PLATE:
{
// MCS feature - stone pressure plates can only be triggered by players :D
- cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.7f, false);
+ cPlayer * a_Player = m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false);
if (a_Player != NULL)
{
@@ -1131,7 +1139,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
else
{
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0);
- m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
}
break;
}
@@ -1155,7 +1163,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
- if (Distance <= 0.7)
+ if (Distance <= 0.5)
{
m_NumberOfEntities++;
}
@@ -1177,7 +1185,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
};
cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ);
- m_World.ForEachEntity(PressurePlateCallback);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback);
unsigned char Power;
NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
@@ -1198,7 +1206,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
}
break;
@@ -1223,7 +1231,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
- if (Distance <= 0.7)
+ if (Distance <= 0.5)
{
m_NumberOfEntities++;
}
@@ -1232,7 +1240,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
bool GetPowerLevel(unsigned char & a_PowerLevel) const
{
- a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / (float)10), MAX_POWER_LEVEL);
+ a_PowerLevel = std::min((int)ceil(m_NumberOfEntities / 10.f), MAX_POWER_LEVEL);
return (a_PowerLevel > 0);
}
@@ -1245,7 +1253,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
};
cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ);
- m_World.ForEachEntity(PressurePlateCallback);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback);
unsigned char Power;
NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
@@ -1266,7 +1274,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
}
break;
@@ -1291,7 +1299,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
Vector3f BlockPos(m_X + 0.5f, (float)m_Y, m_Z + 0.5f);
double Distance = (EntityPos - BlockPos).Length();
- if (Distance <= 0.7)
+ if (Distance <= 0.5)
{
m_FoundEntity = true;
return true; // Break out, we only need to know for plates that at least one entity is on top
@@ -1313,7 +1321,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
} ;
cPressurePlateCallback PressurePlateCallback(BlockX, a_RelBlockY, BlockZ);
- m_World.ForEachEntity(PressurePlateCallback);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), PressurePlateCallback);
NIBBLETYPE Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
if (PressurePlateCallback.FoundEntity())
@@ -1333,7 +1341,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- m_World.WakeUpSimulators(BlockX, a_RelBlockY, BlockZ);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
}
break;
}
@@ -1349,6 +1357,131 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
+void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
+ int RelX = a_RelBlockX, RelZ = a_RelBlockZ;
+ bool FoundActivated = false;
+ eBlockFace FaceToGoTowards = cBlockTripwireHookHandler::MetadataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
+
+ for (int i = 0; i < 40; ++i) // Tripwires can be connected up to 40 blocks
+ {
+ BLOCKTYPE Type;
+ NIBBLETYPE Meta;
+
+ AddFaceDirection(RelX, a_RelBlockY, RelZ, FaceToGoTowards);
+ m_Chunk->UnboundedRelGetBlock(RelX, a_RelBlockY, RelZ, Type, Meta);
+
+ if (Type == E_BLOCK_TRIPWIRE)
+ {
+ if (Meta == 0x1)
+ {
+ FoundActivated = true;
+ }
+ }
+ else if (Type == E_BLOCK_TRIPWIRE_HOOK)
+ {
+ if (ReverseBlockFace(cBlockTripwireHookHandler::MetadataToDirection(Meta)) == FaceToGoTowards)
+ {
+ // Other hook not facing in opposite direction
+ break;
+ }
+ else
+ {
+ // Tripwire hook not connected at all, AND away all the power state bits
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ return;
+ }
+ }
+ else
+ {
+ // Tripwire hook not connected at all, AND away all the power state bits
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ return;
+ }
+ }
+
+ if (FoundActivated)
+ {
+ // Connected and activated, set the 3rd and 4th highest bits
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) | 0xC);
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
+ }
+ else
+ {
+ // Connected but not activated, AND away the highest bit
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7) | 0x4);
+ WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ }
+}
+
+
+
+
+
+void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
+
+ class cTripwireCallback :
+ public cEntityCallback
+ {
+ public:
+ cTripwireCallback(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ m_FoundEntity(false),
+ m_X(a_BlockX),
+ m_Y(a_BlockY),
+ m_Z(a_BlockZ)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ cBoundingBox bbWire(m_X, m_X + 1, m_Y, m_Y + 0.1, m_Z, m_Z + 1);
+ cBoundingBox bbEntity(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
+
+ if (bbEntity.DoesIntersect(bbWire))
+ {
+ m_FoundEntity = true;
+ return true; // One entity is sufficient to trigger the wire
+ }
+ return false;
+ }
+
+ bool FoundEntity(void) const
+ {
+ return m_FoundEntity;
+ }
+
+ protected:
+ bool m_FoundEntity;
+
+ int m_X;
+ int m_Y;
+ int m_Z;
+ };
+
+ cTripwireCallback TripwireCallback(BlockX, a_RelBlockY, BlockZ);
+ m_World.ForEachEntityInChunk(m_Chunk->GetPosX(), m_Chunk->GetPosZ(), TripwireCallback);
+
+ if (TripwireCallback.FoundEntity())
+ {
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1);
+ }
+ else
+ {
+ m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0);
+ }
+}
+
+
+
+
+
bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index 9c1f9460c..6cefdebf2 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -102,6 +102,11 @@ private:
void HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles pressure plates */
void HandlePressurePlate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyType);
+ /** Handles tripwire hooks
+ Performs correct meta and power setting for self by going in the direction it faces and looking for a continous line of tripwire bounded by another oppositely facing hook
+ If this line is complete, it verifies that at least on wire reports an entity is on top (via its meta), and performs its task
+ */
+ void HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/* ==================== */
/* ====== CARRIERS ====== */
@@ -134,6 +139,8 @@ private:
void HandleFenceGate(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles noteblocks */
void HandleNoteBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
+ /** Handles tripwires */
+ void HandleTripwire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/* ===================== */
/* ====== Helper functions ====== */
@@ -271,6 +278,7 @@ private:
case E_BLOCK_TNT:
case E_BLOCK_TRAPDOOR:
case E_BLOCK_TRIPWIRE_HOOK:
+ case E_BLOCK_TRIPWIRE:
case E_BLOCK_WOODEN_BUTTON:
case E_BLOCK_WOODEN_DOOR:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
--
cgit v1.2.3
From 5e66d9aeabcb759319c1045680443e72f0c1d75b Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 28 Jun 2014 20:45:05 +0100
Subject: Fixed issue with breaking blocks at -1 coordinates
---
src/ClientHandle.cpp | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 16cfe1aec..e7b876b24 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1085,12 +1085,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
void cClientHandle::FinishDigAnimation()
{
- if (
- !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet
- (m_LastDigBlockX == -1) ||
- (m_LastDigBlockY == -1) ||
- (m_LastDigBlockZ == -1)
- )
+ if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet
{
return;
}
--
cgit v1.2.3
From 085cb4256ed9dd343ab4049b6f1e3d4ef53855e8 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Sat, 28 Jun 2014 21:55:21 +0200
Subject: Fixed doxycomments
---
src/Bindings/PluginManager.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index e2bd9cd94..545f41107 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -253,10 +253,10 @@ public: // tolua_export
/** Returns the permission needed for the specified command; empty string if command not found */
AString GetCommandPermission(const AString & a_Command); // tolua_export
- /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns true if executed. */
+ /** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns crExecuted if executed. */
CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
- /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns true if executed (false if not found) */
+ /** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns crExecuted if executed. */
CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
/** Removes all console command bindings that the specified plugin has made */
@@ -330,7 +330,7 @@ private:
/** Adds the plugin into the internal list of plugins and initializes it. If initialization fails, the plugin is removed again. */
bool AddPlugin(cPlugin * a_Plugin);
- /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns true if the command is executed. */
+ /** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */
cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
} ; // tolua_export
--
cgit v1.2.3
From 35dc056f0350c5fda178d0c28230f0a6b0feabbc Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 28 Jun 2014 21:10:59 +0100
Subject: Likely fixed too quick food depletion
* Fixes FS427 properly, hopefully
---
src/Entities/Player.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 7b4fd219d..0abe50d11 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1913,7 +1913,7 @@ void cPlayer::HandleFood(void)
{
m_FoodTickTimer = 0;
- if (m_FoodLevel >= 17)
+ if ((m_FoodLevel > 17) && (GetHealth() < GetMaxHealth()))
{
// Regenerate health from food, incur 3 pts of food exhaustion:
Heal(1);
--
cgit v1.2.3
From 536cb62f1c4ee47bf39a04240f9460953f3f8869 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 28 Jun 2014 21:14:10 +0100
Subject: An unification of code style
---
src/Entities/ProjectileEntity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index d45f1d212..76daca186 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -361,7 +361,7 @@ void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
EntityCollisionCallback.GetHitEntity()->GetClass(),
HitPos.x, HitPos.y, HitPos.z,
EntityCollisionCallback.GetMinCoeff()
- );
+ );
OnHitEntity(*(EntityCollisionCallback.GetHitEntity()), HitPos);
}
--
cgit v1.2.3
From 20b32fc44e69ef317dea7536eb8e31bc3fe6c562 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 29 Jun 2014 01:01:10 +0200
Subject: Code fixes.
---
src/WorldStorage/WSSAnvil.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 5c209c7fa..b22454cdf 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -2093,7 +2093,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int ShearedIdx = a_NBT.FindChildByName(a_TagIdx, "Sheared");
if (ShearedIdx > 0)
{
- Monster.get()->SetSheared((bool)a_NBT.GetByte(ShearedIdx));
+ Monster->SetSheared(a_NBT.GetByte(ShearedIdx) != 0);
}
a_Entities.push_back(Monster.release());
--
cgit v1.2.3
From 50e112788bc46460ec2c1972f811264c1a9b04cc Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 29 Jun 2014 01:40:15 +0200
Subject: Send statistics to the player, when he logged in.
---
src/ClientHandle.cpp | 3 +++
src/Protocol/Protocol17x.cpp | 3 +--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 95dfaffb2..abe9a86f5 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -361,6 +361,9 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
// Send scoreboard data
World->GetScoreBoard().SendTo(*this);
+ // Send statistics
+ SendStatistics(m_Player->GetStatManager());
+
// Delay the first ping until the client "settles down"
// This should fix #889, "BadCast exception, cannot convert bit to fm" error in client
cTimer t1;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 49fef0b8e..98fabedb2 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1221,10 +1221,9 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager)
cPacketizer Pkt(*this, 0x37);
Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
- for (unsigned int i = 0; i < (unsigned int)statCount; ++i)
+ for (size_t i = 0; i < (size_t)statCount; ++i)
{
StatValue Value = a_Manager.GetValue((eStatistic) i);
-
const AString & StatName = cStatInfo::GetName((eStatistic) i);
Pkt.WriteString(StatName);
--
cgit v1.2.3
From dde641ce83de474187102f0efbbced826673f54d Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 29 Jun 2014 11:36:38 +0100
Subject: Properly implemented enderchests
---
src/BlockEntities/EnderChestEntity.cpp | 93 +++++++++++----------------------
src/BlockEntities/EnderChestEntity.h | 44 +++++-----------
src/Entities/Player.cpp | 7 +++
src/Entities/Player.h | 11 +++-
src/UI/SlotArea.cpp | 4 +-
src/UI/Window.cpp | 4 +-
src/WorldStorage/NBTChunkSerializer.cpp | 14 +++++
src/WorldStorage/NBTChunkSerializer.h | 2 +
src/WorldStorage/WSSAnvil.cpp | 21 ++++++++
src/WorldStorage/WSSAnvil.h | 1 +
10 files changed, 102 insertions(+), 99 deletions(-)
diff --git a/src/BlockEntities/EnderChestEntity.cpp b/src/BlockEntities/EnderChestEntity.cpp
index e53930798..17816d63e 100644
--- a/src/BlockEntities/EnderChestEntity.cpp
+++ b/src/BlockEntities/EnderChestEntity.cpp
@@ -12,9 +12,8 @@
cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
+ super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, a_World)
{
- cBlockEntityWindowOwner::SetBlockEntity(this);
}
@@ -34,95 +33,63 @@ cEnderChestEntity::~cEnderChestEntity()
-bool cEnderChestEntity::LoadFromJson(const Json::Value & a_Value)
+void cEnderChestEntity::UsedBy(cPlayer * a_Player)
{
- m_PosX = a_Value.get("x", 0).asInt();
- m_PosY = a_Value.get("y", 0).asInt();
- m_PosZ = a_Value.get("z", 0).asInt();
-
- Json::Value AllSlots = a_Value.get("Slots", 0);
- int SlotIdx = 0;
- for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
+ // If the window is not created, open it anew:
+ cWindow * Window = GetWindow();
+ if (Window == NULL)
{
- cItem Item;
- Item.FromJson(*itr);
- SetSlot(SlotIdx, Item);
- SlotIdx++;
+ OpenNewWindow();
+ Window = GetWindow();
}
- return true;
-}
-
-
-
-
-
-void cEnderChestEntity::SaveToJson(Json::Value & a_Value)
-{
- a_Value["x"] = m_PosX;
- a_Value["y"] = m_PosY;
- a_Value["z"] = m_PosZ;
-
- Json::Value AllSlots;
- for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
+
+ // Open the window for the player:
+ if (Window != NULL)
{
- Json::Value Slot;
- m_Contents.GetSlot(i).GetJson(Slot);
- AllSlots.append(Slot);
+ if (a_Player->GetWindow() != Window)
+ {
+ a_Player->OpenWindow(Window);
+ }
}
- a_Value["Slots"] = AllSlots;
}
-void cEnderChestEntity::SendTo(cClientHandle & a_Client)
+void cEnderChestEntity::OpenNewWindow()
{
- // The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
- // All the actual handling is in the cWindow UI code that gets called when the chest is rclked
-
- UNUSED(a_Client);
+ OpenWindow(new cEnderChestWindow(this));
}
-void cEnderChestEntity::UsedBy(cPlayer * a_Player)
+void cEnderChestEntity::LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid)
{
- // If the window is not created, open it anew:
- cWindow * Window = GetWindow();
- if (Window == NULL)
- {
- OpenNewWindow();
- Window = GetWindow();
- }
-
- // Open the window for the player:
- if (Window != NULL)
+ int SlotIdx = 0;
+ for (Json::Value::iterator itr = a_Value.begin(); itr != a_Value.end(); ++itr)
{
- if (a_Player->GetWindow() != Window)
- {
- a_Player->OpenWindow(Window);
- }
+ cItem Item;
+ Item.FromJson(*itr);
+ a_Grid.SetSlot(SlotIdx, Item);
+ SlotIdx++;
}
-
- // This is rather a hack
- // Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now
- // We cannot properly detect contents change, but such a change doesn't happen without a player opening the chest first.
- // The few false positives aren't much to worry about
- int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ);
- m_World->MarkChunkDirty(ChunkX, ChunkZ);
}
-void cEnderChestEntity::OpenNewWindow(void)
+void cEnderChestEntity::SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid)
{
- OpenWindow(new cEnderChestWindow(this));
+ for (int i = 0; i < a_Grid.GetNumSlots(); i++)
+ {
+ Json::Value Slot;
+ a_Grid.GetSlot(i).GetJson(Slot);
+ a_Value.append(Slot);
+ }
}
diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h
index 45beee45f..04af67683 100644
--- a/src/BlockEntities/EnderChestEntity.h
+++ b/src/BlockEntities/EnderChestEntity.h
@@ -1,20 +1,9 @@
#pragma once
-#include "BlockEntityWithItems.h"
-
-
-
-
-
-namespace Json
-{
- class Value;
-};
-
-class cClientHandle;
-class cServer;
-class cNBTData;
+#include "BlockEntity.h"
+#include "UI/WindowOwner.h"
+#include "json/json.h"
@@ -22,33 +11,28 @@ class cNBTData;
// tolua_begin
class cEnderChestEntity :
- public cBlockEntityWithItems
+ public cBlockEntity,
+ public cBlockEntityWindowOwner
{
- typedef cBlockEntityWithItems super;
-
-public:
- enum {
- ContentsHeight = 3,
- ContentsWidth = 9,
- } ;
+ typedef cBlockEntity super;
+public:
// tolua_end
- /// Constructor used for normal operation
- cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
-
+ cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cEnderChestEntity();
static const char * GetClassStatic(void) { return "cEnderChestEntity"; }
-
- bool LoadFromJson(const Json::Value & a_Value);
// cBlockEntity overrides:
- virtual void SaveToJson(Json::Value & a_Value) override;
- virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
+ virtual void SaveToJson(Json::Value & a_Value) override { UNUSED(a_Value); }
+ virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); }
+
+ static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid);
+ static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid);
- /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
+ /** Opens a new enderchest window for this enderchest */
void OpenNewWindow(void);
} ; // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 0abe50d11..aeeea3d07 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -8,6 +8,7 @@
#include "../World.h"
#include "../Bindings/PluginManager.h"
#include "../BlockEntities/BlockEntity.h"
+#include "../BlockEntities/EnderChestEntity.h"
#include "../GroupManager.h"
#include "../Group.h"
#include "../Root.h"
@@ -46,6 +47,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_bTouchGround(false)
, m_Stance(0.0)
, m_Inventory(*this)
+ , m_EnderChestContents(9, 3)
, m_CurrentWindow(NULL)
, m_InventoryWindow(NULL)
, m_Color('-')
@@ -1743,6 +1745,7 @@ bool cPlayer::LoadFromDisk()
}
m_Inventory.LoadFromJson(root["inventory"]);
+ cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents);
m_LoadedWorldName = root.get("world", "world").asString();
@@ -1780,10 +1783,14 @@ bool cPlayer::SaveToDisk()
Json::Value JSON_Inventory;
m_Inventory.SaveToJson(JSON_Inventory);
+ Json::Value JSON_EnderChestInventory;
+ cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents);
+
Json::Value root;
root["position"] = JSON_PlayerPosition;
root["rotation"] = JSON_PlayerRotation;
root["inventory"] = JSON_Inventory;
+ root["enderchestinventory"] = JSON_EnderChestInventory;
root["health"] = m_Health;
root["xpTotal"] = m_LifetimeTotalXp;
root["xpCurrent"] = m_CurrentXp;
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 2f7957f16..c70733c8c 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -124,6 +124,9 @@ public:
inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc.
inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export
inline const cInventory & GetInventory(void) const { return m_Inventory; }
+
+ /** Gets the contents of the player's associated enderchest */
+ cItemGrid & GetEnderChestContents(void) { return m_EnderChestContents; }
inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export
@@ -449,7 +452,13 @@ protected:
float m_LastGroundHeight;
bool m_bTouchGround;
double m_Stance;
+
+ /** Stores the player's inventory, consisting of crafting grid, hotbar, and main slots */
cInventory m_Inventory;
+
+ /** An item grid that stores the player specific enderchest contents */
+ cItemGrid m_EnderChestContents;
+
cWindow * m_CurrentWindow;
cWindow * m_InventoryWindow;
@@ -510,8 +519,6 @@ protected:
cStatManager m_Stats;
-
-
/** Sets the speed and sends it to the client, so that they are forced to move so. */
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 728692f2a..a2661e49e 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -1342,7 +1342,7 @@ cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWind
const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const
{
// a_SlotNum ranges from 0 to 26, use that to index the chest entity's inventory directly:
- return &(m_EnderChest->GetSlot(a_SlotNum));
+ return &(a_Player.GetEnderChestContents().GetSlot(a_SlotNum));
}
@@ -1351,7 +1351,7 @@ const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) co
void cSlotAreaEnderChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
{
- m_EnderChest->SetSlot(a_SlotNum, a_Item);
+ a_Player.GetEnderChestContents().SetSlot(a_SlotNum, a_Item);
}
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 98a9a0cec..81f75cebb 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -145,8 +145,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const
{
int NumSlots = (*itr)->GetNumSlots();
for (int i = 0; i < NumSlots; i++)
- {
-
+ {
const cItem * Item = (*itr)->GetSlot(i, a_Player);
if (Item == NULL)
{
@@ -1017,6 +1016,7 @@ cEnderChestWindow::~cEnderChestWindow()
// Send out the chest-close packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST);
+ // Play the closing sound
m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
}
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index f35b38859..baf74d830 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -11,6 +11,7 @@
#include "FastNBT.h"
#include "../BlockEntities/ChestEntity.h"
+#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/DispenserEntity.h"
#include "../BlockEntities/DropperEntity.h"
@@ -189,6 +190,18 @@ void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
+void cNBTChunkSerializer::AddEnderChestEntity(cEnderChestEntity * a_Entity)
+{
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Entity, "EnderChest");
+ // No need to store anything more
+ m_Writer.EndCompound();
+}
+
+
+
+
+
void cNBTChunkSerializer::AddDispenserEntity(cDispenserEntity * a_Entity)
{
m_Writer.BeginCompound("");
@@ -820,6 +833,7 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break;
case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
+ case E_BLOCK_ENDER_CHEST: AddEnderChestEntity ((cEnderChestEntity *) a_Entity); break;
case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index 112afc27e..a4c95f540 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -21,6 +21,7 @@ class cEntity;
class cBlockEntity;
class cBoat;
class cChestEntity;
+class cEnderChestEntity;
class cCommandBlockEntity;
class cDispenserEntity;
class cDropperEntity;
@@ -93,6 +94,7 @@ protected:
// Block entities:
void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID);
void AddChestEntity (cChestEntity * a_Entity);
+ void AddEnderChestEntity(cEnderChestEntity * a_Entity);
void AddDispenserEntity(cDispenserEntity * a_Entity);
void AddDropperEntity (cDropperEntity * a_Entity);
void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 9870c144a..e6170f8b7 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -16,6 +16,7 @@
#include "../StringCompression.h"
#include "../BlockEntities/ChestEntity.h"
+#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/DispenserEntity.h"
#include "../BlockEntities/DropperEntity.h"
@@ -583,6 +584,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0)
{
LoadChestFromNBT(a_BlockEntities, a_NBT, Child);
+ }
+ else if (strncmp(a_NBT.GetData(sID), "EnderChest", a_NBT.GetDataLength(sID)) == 0)
+ {
+
}
else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0)
{
@@ -762,6 +767,22 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars
+void cWSSAnvil::LoadEnderChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
+ int x, y, z;
+ if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z))
+ {
+ return;
+ }
+ std::auto_ptr EnderChest(new cEnderChestEntity(x, y, z, m_World));
+ a_BlockEntities.push_back(EnderChest.release());
+}
+
+
+
+
+
void cWSSAnvil::LoadDispenserFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
{
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 7542a828a..45fea70b6 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -134,6 +134,7 @@ protected:
void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0);
void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadEnderChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
--
cgit v1.2.3
From 909e0ed95b508b0cc3779df342899e8661e6da96 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 29 Jun 2014 11:41:50 +0100
Subject: Removed bad comment
---
src/UI/SlotArea.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index a2661e49e..48ebf489b 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -1341,7 +1341,6 @@ cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWind
const cItem * cSlotAreaEnderChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const
{
- // a_SlotNum ranges from 0 to 26, use that to index the chest entity's inventory directly:
return &(a_Player.GetEnderChestContents().GetSlot(a_SlotNum));
}
--
cgit v1.2.3
From 3c631fc0f95f383c53d18cd7760ab2e3a8609240 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Sun, 29 Jun 2014 18:27:41 +0200
Subject: Fixed offline UUID generator.
It generated invalid UUIDs, too many hex chars.
---
src/ClientHandle.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index abe9a86f5..662ee7927 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -241,9 +241,11 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username)
// Generate an md5 checksum, and use it as base for the ID:
unsigned char MD5[16];
md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5);
+ MD5[6] &= 0x0f; // Need to trim to 4 bits only...
+ MD5[8] &= 0x0f; // ... otherwise %01x overflows into two chars
return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x",
- MD5[0], MD5[1], MD5[2], MD5[3],
- MD5[4], MD5[5], MD5[6], MD5[7],
+ MD5[0], MD5[1], MD5[2], MD5[3],
+ MD5[4], MD5[5], MD5[6], MD5[7],
MD5[8], MD5[9], MD5[10], MD5[11],
MD5[12], MD5[13], MD5[14], MD5[15]
);
--
cgit v1.2.3
From 428cfb5c21ec5a35252b967eb306d6ba9b8e11b3 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 29 Jun 2014 22:41:31 +0100
Subject: Suggestions
---
src/Entities/ArrowEntity.cpp | 4 +++-
src/Entities/Entity.cpp | 5 +++--
src/Vector3.h | 14 ++++++++++++++
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index db9dc781a..c76c710ef 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -69,7 +69,9 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
Vector3d Hit = a_HitPos;
- Hit += GetSpeed() / 700; // Make arrow sink into block a little
+ Vector3d SinkMovement = GetSpeed() / 800;
+ SinkMovement.Clamp(0.001, 0.001, 0.001, 0.05, 0.05, 0.05);
+ Hit += SinkMovement; // Make arrow sink into block a little
super::OnHitSolidBlock(Hit, a_HitFace);
int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z);
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index f4e89367b..1683aa209 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -255,7 +255,8 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
void cEntity::SetYawFromSpeed(void)
{
- if ((abs(m_Speed.x) < std::numeric_limits::epsilon()) && (abs(m_Speed.z) < std::numeric_limits::epsilon()))
+ const double EPS = 0.0000001;
+ if ((abs(m_Speed.x) < EPS) && (abs(m_Speed.z) < EPS))
{
// atan2() may overflow or is undefined, pick any number
SetYaw(0);
@@ -1235,7 +1236,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
if (GetWorld()->GetWorldAge() % 2 == 0)
{
double SpeedSqr = GetSpeed().SqrLength();
- if (SpeedSqr < std::numeric_limits::epsilon())
+ if (SpeedSqr == 0.0)
{
// Speed is zero, send this to clients once only as well as an absolute position
if (!m_bHasSentNoSpeed)
diff --git a/src/Vector3.h b/src/Vector3.h
index 5faac1457..762fdfd71 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -274,6 +274,14 @@ public:
return (a_X - x) / (a_OtherEnd.x - x);
}
+ /** Clamps each value in the vector to within a specified range */
+ inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ)
+ {
+ x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x));
+ y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y));
+ z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z));
+ }
+
/** The max difference between two coords for which the coords are assumed equal. */
static const double EPS;
@@ -288,6 +296,12 @@ protected:
{
return (a_Value < 0) ? -a_Value : a_Value;
}
+
+ /** Clamp X to the specified range. */
+ T Clamp(T a_Value, T a_Min, T a_Max)
+ {
+ return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value);
+ }
};
// tolua_end
--
cgit v1.2.3
From b9d4431f6f2b60802d66da03f0b915bbd2c846cb Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 29 Jun 2014 22:44:01 +0100
Subject: Fixed respawning
* Fixes #1103
---
src/ClientHandle.cpp | 4 ++--
src/ClientHandle.h | 2 +-
src/Entities/Player.cpp | 2 +-
src/Protocol/Protocol.h | 2 +-
src/Protocol/Protocol125.cpp | 6 +++---
src/Protocol/Protocol125.h | 2 +-
src/Protocol/Protocol16x.cpp | 4 ++--
src/Protocol/Protocol16x.h | 2 +-
src/Protocol/Protocol17x.cpp | 6 +++---
src/Protocol/Protocol17x.h | 2 +-
src/Protocol/ProtocolRecognizer.cpp | 4 ++--
src/Protocol/ProtocolRecognizer.h | 2 +-
12 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 662ee7927..6b71f0924 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2397,9 +2397,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec
-void cClientHandle::SendRespawn(const cWorld & a_World)
+void cClientHandle::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks)
{
- m_Protocol->SendRespawn(a_World);
+ m_Protocol->SendRespawn(a_World, a_ShouldIgnoreDimensionChecks);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 02bc0c719..6f2c86b27 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -156,7 +156,7 @@ public:
void SendPlayerSpawn (const cPlayer & a_Player);
void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp
void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID);
- void SendRespawn (const cWorld & a_World);
+ void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false);
void SendExperience (void);
void SendExperienceOrb (const cExpOrb & a_ExpOrb);
void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 0abe50d11..daf1ef2cc 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -976,7 +976,7 @@ void cPlayer::Respawn(void)
m_LifetimeTotalXp = 0;
// ToDo: send score to client? How?
- m_ClientHandle->SendRespawn(*m_World);
+ m_ClientHandle->SendRespawn(*m_World, true);
// Extinguish the fire:
StopBurning();
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index e08a5a51b..ac872a2f2 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -100,7 +100,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0;
- virtual void SendRespawn (const cWorld & a_World) = 0;
+ virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) = 0;
virtual void SendExperience (void) = 0;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) = 0;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0;
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index d53427bf7..6dc2e918d 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -833,12 +833,12 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
-void cProtocol125::SendRespawn(const cWorld & a_World)
+void cProtocol125::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks)
{
cCSLock Lock(m_CSPacket);
- if (m_LastSentDimension == a_World.GetDimension())
+ if ((m_LastSentDimension == a_World.GetDimension()) && !a_ShouldIgnoreDimensionChecks)
{
- // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do
+ // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death)
return;
}
cPlayer * Player = m_Client->GetPlayer();
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 747bf512d..9dbefd3a3 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -72,7 +72,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendRespawn (const cWorld & a_World) override;
+ virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp
index 9e0f3f852..eba795f61 100644
--- a/src/Protocol/Protocol16x.cpp
+++ b/src/Protocol/Protocol16x.cpp
@@ -158,10 +158,10 @@ void cProtocol161::SendPlayerMaxSpeed(void)
-void cProtocol161::SendRespawn(const cWorld & a_World)
+void cProtocol161::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks)
{
// Besides sending the respawn, we need to also send the player max speed, otherwise the client reverts to super-fast
- super::SendRespawn(a_World);
+ super::SendRespawn(a_World, a_ShouldIgnoreDimensionChecks);
SendPlayerMaxSpeed();
}
diff --git a/src/Protocol/Protocol16x.h b/src/Protocol/Protocol16x.h
index e91dc8a1c..e6e79027e 100644
--- a/src/Protocol/Protocol16x.h
+++ b/src/Protocol/Protocol16x.h
@@ -42,7 +42,7 @@ protected:
virtual void SendGameMode (eGameMode a_GameMode) override;
virtual void SendHealth (void) override;
virtual void SendPlayerMaxSpeed(void) override;
- virtual void SendRespawn (const cWorld & a_World) override;
+ virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual int ParseEntityAction (void) override;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 98fabedb2..df9c6b50d 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -986,11 +986,11 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
-void cProtocol172::SendRespawn(const cWorld & a_World)
+void cProtocol172::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks)
{
- if (m_LastSentDimension == a_World.GetDimension())
+ if ((m_LastSentDimension == a_World.GetDimension()) && !a_ShouldIgnoreDimensionChecks)
{
- // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do
+ // Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do (unless we are respawning from death)
return;
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 07c8c8459..1a65cfa1c 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -104,7 +104,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendRespawn (const cWorld & a_World) override;
+ virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 2436c49c3..c0c9e08ee 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -556,10 +556,10 @@ void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a
-void cProtocolRecognizer::SendRespawn(const cWorld & a_World)
+void cProtocolRecognizer::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendRespawn(a_World);
+ m_Protocol->SendRespawn(a_World, a_ShouldIgnoreDimensionChecks);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index a5a6c59b6..0a9a42e93 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -107,7 +107,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
- virtual void SendRespawn (const cWorld & a_World) override;
+ virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
--
cgit v1.2.3
From 4ded58bfd1066d237588c542e511759e504c5c95 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 30 Jun 2014 14:19:31 +0200
Subject: Unnecessary return
---
src/ClientHandle.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 6b71f0924..efa734b44 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1223,9 +1223,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// A plugin won't let us eat, abort (send the proper packets to the client, too):
m_Player->AbortEating();
- return;
}
- return;
}
else
{
--
cgit v1.2.3
From aa753a92c092a4d35b2ff7d08259c3196abecf67 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 30 Jun 2014 15:12:56 +0200
Subject: Add new hook: HOOK_PLAYER_FOOD_LEVEL_CHANGE
---
src/Bindings/Plugin.h | 1 +
src/Bindings/PluginLua.cpp | 20 +++++++++++++++++
src/Bindings/PluginLua.h | 1 +
src/Bindings/PluginManager.cpp | 19 ++++++++++++++++
src/Bindings/PluginManager.h | 2 ++
src/Entities/Player.cpp | 50 ++++++++++++++++++++----------------------
6 files changed, 67 insertions(+), 26 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index c6461c861..254209bd2 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -72,6 +72,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) = 0;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0;
+ virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) = 0;
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;
virtual bool OnPlayerMoved (cPlayer & a_Player) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 96c5ccde7..be27340ad 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -715,6 +715,26 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player)
+bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
{
cCSLock Lock(m_CriticalSection);
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 598e031c0..cf244f33d 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -95,6 +95,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) override;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override;
+ virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) override;
virtual bool OnPlayerJoined (cPlayer & a_Player) override;
virtual bool OnPlayerMoved (cPlayer & a_Player) override;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index c50100d6f..936c6b8a8 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -695,6 +695,25 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
+bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel)
+{
+ FIND_HOOK(HOOK_PLAYER_FOOD_LEVEL_CHANGE);
+ VERIFY_HOOK;
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnPlayerFoodLevelChange(a_Player, a_NewFoodLevel))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward)
{
FIND_HOOK(HOOK_PLAYER_FISHED);
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index be40bd2f7..560a5c1d3 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -87,6 +87,7 @@ public: // tolua_export
HOOK_PLAYER_EATING,
HOOK_PLAYER_FISHED,
HOOK_PLAYER_FISHING,
+ HOOK_PLAYER_FOOD_LEVEL_CHANGE,
HOOK_PLAYER_JOINED,
HOOK_PLAYER_LEFT_CLICK,
HOOK_PLAYER_MOVING,
@@ -188,6 +189,7 @@ public: // tolua_export
bool CallHookPlayerEating (cPlayer & a_Player);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
+ bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
bool CallHookPlayerMoving (cPlayer & a_Player);
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index daf1ef2cc..ed18d2ab7 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -37,9 +37,9 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
: super(etPlayer, 0.6, 1.8)
, m_bVisible(true)
, m_FoodLevel(MAX_FOOD_LEVEL)
- , m_FoodSaturationLevel(5)
+ , m_FoodSaturationLevel(5.0)
, m_FoodTickTimer(0)
- , m_FoodExhaustionLevel(0)
+ , m_FoodExhaustionLevel(0.0)
, m_FoodPoisonedTicksRemaining(0)
, m_LastJumpHeight(0)
, m_LastGroundHeight(0)
@@ -521,7 +521,15 @@ void cPlayer::Heal(int a_Health)
void cPlayer::SetFoodLevel(int a_FoodLevel)
{
- m_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
+ a_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
+
+ if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, a_FoodLevel))
+ {
+ m_FoodSaturationLevel = 5.0;
+ return;
+ }
+
+ m_FoodLevel = a_FoodLevel;
SendHealth();
}
@@ -571,11 +579,9 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
{
return false;
}
-
- m_FoodLevel = std::min(a_Food + m_FoodLevel, (int)MAX_FOOD_LEVEL);
- m_FoodSaturationLevel = std::min(m_FoodSaturationLevel + a_Saturation, (double)m_FoodLevel);
-
- SendHealth();
+
+ SetFoodSaturationLevel(m_FoodSaturationLevel + a_Saturation);
+ SetFoodLevel(m_FoodLevel + a_Food);
return true;
}
@@ -969,7 +975,7 @@ void cPlayer::Respawn(void)
// Reset food level:
m_FoodLevel = MAX_FOOD_LEVEL;
- m_FoodSaturationLevel = 5;
+ m_FoodSaturationLevel = 5.0;
// Reset Experience
m_CurrentXp = 0;
@@ -1895,16 +1901,13 @@ void cPlayer::TickBurning(cChunk & a_Chunk)
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
-
+
if (IsGameModeCreative())
{
// Hunger is disabled for Creative
return;
}
-
- // Remember the food level before processing, for later comparison
- int LastFoodLevel = m_FoodLevel;
-
+
// Heal or damage, based on the food level, using the m_FoodTickTimer:
if ((m_FoodLevel > 17) || (m_FoodLevel <= 0))
{
@@ -1917,7 +1920,7 @@ void cPlayer::HandleFood(void)
{
// Regenerate health from food, incur 3 pts of food exhaustion:
Heal(1);
- m_FoodExhaustionLevel += 3;
+ m_FoodExhaustionLevel += 3.0;
}
else if ((m_FoodLevel <= 0) && (m_Health > 1))
{
@@ -1926,7 +1929,7 @@ void cPlayer::HandleFood(void)
}
}
}
-
+
// Apply food poisoning food exhaustion:
if (m_FoodPoisonedTicksRemaining > 0)
{
@@ -1939,24 +1942,19 @@ void cPlayer::HandleFood(void)
}
// Apply food exhaustion that has accumulated:
- if (m_FoodExhaustionLevel >= 4)
+ if (m_FoodExhaustionLevel >= 4.0)
{
- m_FoodExhaustionLevel -= 4;
+ m_FoodExhaustionLevel -= 4.0;
- if (m_FoodSaturationLevel >= 1)
+ if (m_FoodSaturationLevel >= 1.0)
{
- m_FoodSaturationLevel -= 1;
+ m_FoodSaturationLevel -= 1.0;
}
else
{
- m_FoodLevel = std::max(m_FoodLevel - 1, 0);
+ SetFoodLevel(m_FoodLevel - 1);
}
}
-
- if (m_FoodLevel != LastFoodLevel)
- {
- SendHealth();
- }
}
--
cgit v1.2.3
From 5a152435b3fa1452a842519e21ab0643020bc1ab Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 30 Jun 2014 15:22:48 +0200
Subject: Add documentation.
---
.../APIDump/Hooks/OnPlayerFoodLevelChange.lua | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
new file mode 100644
index 000000000..4838573e5
--- /dev/null
+++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
@@ -0,0 +1,22 @@
+return
+{
+ HOOK_PLAYER_FOOD_LEVEL_CHANGE =
+ {
+ CalledWhen = "Called before the player food level changed. Plugin may override / refuse.",
+ DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename
+ Desc = [[
+ This hook is called just before the food level change.
+ The food level is not yet changed, plugins may choose to override the new food level or refuse the change.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who change the food level." },
+ { Name = "NewFoodLevel", Type = "number", Notes = "The new food level." },
+ },
+ Returns = [[
+ If the function returns false or no value, the next plugin's callback is called. Afterwards, the
+ server change the food level from the player. If the function returns true, no
+ other callback is called for this event and the player's food level doesn't change.
+ ]],
+ }, -- HOOK_PLAYER_FOOD_LEVEL_CHANGE
+};
--
cgit v1.2.3
From b94fef3089003b6b8958716cc8d12ffa03b5a779 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 30 Jun 2014 19:15:10 +0100
Subject: Removed unneeded code
---
src/WorldStorage/NBTChunkSerializer.cpp | 15 +--------------
src/WorldStorage/NBTChunkSerializer.h | 2 --
src/WorldStorage/WSSAnvil.cpp | 21 ---------------------
src/WorldStorage/WSSAnvil.h | 1 -
4 files changed, 1 insertion(+), 38 deletions(-)
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index baf74d830..bff515386 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -11,7 +11,6 @@
#include "FastNBT.h"
#include "../BlockEntities/ChestEntity.h"
-#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/DispenserEntity.h"
#include "../BlockEntities/DropperEntity.h"
@@ -190,18 +189,6 @@ void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
-void cNBTChunkSerializer::AddEnderChestEntity(cEnderChestEntity * a_Entity)
-{
- m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "EnderChest");
- // No need to store anything more
- m_Writer.EndCompound();
-}
-
-
-
-
-
void cNBTChunkSerializer::AddDispenserEntity(cDispenserEntity * a_Entity)
{
m_Writer.BeginCompound("");
@@ -833,7 +820,7 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break;
case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
- case E_BLOCK_ENDER_CHEST: AddEnderChestEntity ((cEnderChestEntity *) a_Entity); break;
+ case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break;
case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index a4c95f540..112afc27e 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -21,7 +21,6 @@ class cEntity;
class cBlockEntity;
class cBoat;
class cChestEntity;
-class cEnderChestEntity;
class cCommandBlockEntity;
class cDispenserEntity;
class cDropperEntity;
@@ -94,7 +93,6 @@ protected:
// Block entities:
void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID);
void AddChestEntity (cChestEntity * a_Entity);
- void AddEnderChestEntity(cEnderChestEntity * a_Entity);
void AddDispenserEntity(cDispenserEntity * a_Entity);
void AddDropperEntity (cDropperEntity * a_Entity);
void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index e6170f8b7..9870c144a 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -16,7 +16,6 @@
#include "../StringCompression.h"
#include "../BlockEntities/ChestEntity.h"
-#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/DispenserEntity.h"
#include "../BlockEntities/DropperEntity.h"
@@ -584,10 +583,6 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0)
{
LoadChestFromNBT(a_BlockEntities, a_NBT, Child);
- }
- else if (strncmp(a_NBT.GetData(sID), "EnderChest", a_NBT.GetDataLength(sID)) == 0)
- {
-
}
else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0)
{
@@ -767,22 +762,6 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars
-void cWSSAnvil::LoadEnderChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
-{
- ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
- int x, y, z;
- if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z))
- {
- return;
- }
- std::auto_ptr EnderChest(new cEnderChestEntity(x, y, z, m_World));
- a_BlockEntities.push_back(EnderChest.release());
-}
-
-
-
-
-
void cWSSAnvil::LoadDispenserFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
{
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 45fea70b6..7542a828a 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -134,7 +134,6 @@ protected:
void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0);
void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
- void LoadEnderChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
--
cgit v1.2.3
From 85fae0e521d3a2ea4f083ee2bc54ac7fbb357768 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 30 Jun 2014 19:21:21 +0100
Subject: Implemented Vector3<>::Floor()
---
src/Entities/ArrowEntity.cpp | 5 +++--
src/Vector3.h | 24 ++++++++++++++++--------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index c76c710ef..2d6683f0a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -74,8 +74,9 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
Hit += SinkMovement; // Make arrow sink into block a little
super::OnHitSolidBlock(Hit, a_HitFace);
- int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z);
-
+ Hit.Floor();
+
+ int X = Hit.x, Y = Hit.y, Z = Hit.z;
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
diff --git a/src/Vector3.h b/src/Vector3.h
index 762fdfd71..b5ddc705a 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -134,6 +134,22 @@ public:
z += a_Diff.z;
}
+ /** Runs each value of the vector through std::floor() */
+ inline void Floor(void)
+ {
+ x = (T)floor(x);
+ y = (T)floor(y);
+ z = (T)floor(z);
+ }
+
+ /** Clamps each value in the vector to within a specified range */
+ inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ)
+ {
+ x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x));
+ y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y));
+ z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z));
+ }
+
// tolua_end
inline bool operator != (const Vector3 & a_Rhs) const
@@ -274,14 +290,6 @@ public:
return (a_X - x) / (a_OtherEnd.x - x);
}
- /** Clamps each value in the vector to within a specified range */
- inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ)
- {
- x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x));
- y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y));
- z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z));
- }
-
/** The max difference between two coords for which the coords are assumed equal. */
static const double EPS;
--
cgit v1.2.3
From c3cde6232fae96a1c196d6bdf63b17ae996aee24 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 30 Jun 2014 20:23:17 +0200
Subject: Moved the random code to a function
(cSheep::GenerateNaturalRandomColor())
---
src/Mobs/Sheep.cpp | 72 ++++++++++++++++++++++++++++++------------------------
src/Mobs/Sheep.h | 11 ++++++---
2 files changed, 47 insertions(+), 36 deletions(-)
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index cc7315a86..e208aa891 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -20,39 +20,12 @@ cSheep::cSheep(int a_Color) :
// Generate random wool color.
if (m_WoolColor == -1)
{
- cFastRandom Random;
- int Chance = Random.NextInt(101);
+ m_WoolColor = GenerateNaturalRandomColor();
+ }
- if (Chance <= 81)
- {
- // White
- m_WoolColor = 0;
- }
- else if (Chance <= 86)
- {
- // Black
- m_WoolColor = 15;
- }
- else if (Chance <= 91)
- {
- // Grey
- m_WoolColor = 7;
- }
- else if (Chance <= 96)
- {
- // Light grey
- m_WoolColor = 8;
- }
- else if (Chance <= 99)
- {
- // Brown
- m_WoolColor = 12;
- }
- else
- {
- // Pink
- m_WoolColor = 6;
- }
+ if ((m_WoolColor < 0) || (m_WoolColor > 15))
+ {
+ m_WoolColor = 0;
}
}
@@ -148,3 +121,38 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
}
}
+
+
+
+
+NIBBLETYPE cSheep::GenerateNaturalRandomColor(void)
+{
+ cFastRandom Random;
+ int Chance = Random.NextInt(101);
+
+ if (Chance <= 81)
+ {
+ return E_META_WOOL_WHITE;
+ }
+ else if (Chance <= 86)
+ {
+ return E_META_WOOL_BLACK;
+ }
+ else if (Chance <= 91)
+ {
+ return E_META_WOOL_GRAY;
+ }
+ else if (Chance <= 96)
+ {
+ return E_META_WOOL_LIGHTGRAY;
+ }
+ else if (Chance <= 99)
+ {
+ return E_META_WOOL_BROWN;
+ }
+ else
+ {
+ return E_META_WOOL_PINK;
+ }
+}
+
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 21dca7787..41de7924f 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -13,24 +13,27 @@ class cSheep :
typedef cPassiveMonster super;
public:
+
+ /** Use -1 for random color. */
cSheep(int a_Color = -1);
-
+
CLASS_PROTODEF(cSheep);
-
+
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
+ static NIBBLETYPE GenerateNaturalRandomColor(void);
+
bool IsSheared(void) const { return m_IsSheared; }
void SetSheared(bool a_IsSheared) { m_IsSheared = a_IsSheared; }
int GetFurColor(void) const { return m_WoolColor; }
- void SetFurColor(bool a_WoolColor) { m_WoolColor = a_WoolColor; }
+ void SetFurColor(int a_WoolColor) { m_WoolColor = a_WoolColor; }
private:
-
bool m_IsSheared;
int m_WoolColor;
int m_TimeToStopEating;
--
cgit v1.2.3
From 6b8529544e7def8acb38ca80c01b4875ae313681 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Mon, 30 Jun 2014 21:00:06 +0200
Subject: Fixed tolua linking order.
Ref.: #1044.
---
lib/tolua++/CMakeLists.txt | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt
index e68a0e15b..44a4f1c6f 100644
--- a/lib/tolua++/CMakeLists.txt
+++ b/lib/tolua++/CMakeLists.txt
@@ -44,8 +44,6 @@ file(GLOB BIN_SOURCE
"src/bin/*.c"
)
-
-
add_executable(tolua ${BIN_SOURCE})
add_library(tolualib ${LIB_SOURCE})
@@ -54,4 +52,4 @@ if(UNIX)
target_link_libraries(tolua m ${DYNAMIC_LOADER})
endif()
-target_link_libraries(tolua lua tolualib)
+target_link_libraries(tolua tolualib lua)
--
cgit v1.2.3
From a5a0533d793a64b76a84f23d4ca1754571ee0b40 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Mon, 30 Jun 2014 21:41:14 +0200
Subject: Fixed cFile compilation under MinGW.
---
src/OSSupport/File.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 8c24fa541..addf8f928 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -7,6 +7,9 @@
#include "File.h"
#include
+#ifdef _WIN32
+ #include // for _SH_DENYWRITE
+#endif // _WIN32
--
cgit v1.2.3
From ac01a8e483f84d94f57c38d6882acd31d7e0fc91 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Mon, 30 Jun 2014 21:27:13 +0200
Subject: Fixed lua compilation under MinGW.
---
lib/lua/CMakeLists.txt | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt
index 6e5e0f565..0a04d1ee6 100644
--- a/lib/lua/CMakeLists.txt
+++ b/lib/lua/CMakeLists.txt
@@ -11,21 +11,16 @@ file(GLOB SOURCE
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.c" "${PROJECT_SOURCE_DIR}/src/luac.c")
# add headers to MSVC project files:
-if (WIN32)
+if (MSVC)
file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS})
source_group("Sources" FILES ${SOURCE})
endif()
+
# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work
if (WIN32)
-
- #for compiliers other than msvc we need to tell lua that its building as a dll
- if (NOT MSVC)
- add_flags_cxx(-DLUA_BUILD_AS_DLL=1)
- endif()
-
add_library(lua SHARED ${SOURCE})
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
@@ -53,7 +48,7 @@ if (WIN32)
)
endif()
- set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51")
+ set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51" PREFIX "")
# NOTE: The DLL for each configuration is stored at the same place, thus overwriting each other.
# This is known, however such behavior is needed for LuaRocks - they always load "lua5.1.dll" or "lua51.dll"
@@ -63,6 +58,7 @@ else()
add_library(lua ${SOURCE})
endif()
+
# Tell Lua what dynamic loader to use (for LuaRocks):
if (UNIX)
add_definitions(-DLUA_USE_DLOPEN)
--
cgit v1.2.3
From 8e11f7a1f64fd4d20495f1a4467ef168d18db92b Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 30 Jun 2014 21:50:40 +0200
Subject: Fixes.
---
src/Bindings/PluginLua.cpp | 2 +-
src/Entities/Player.cpp | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index be27340ad..2d485a117 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -722,7 +722,7 @@ bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLeve
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res, a_NewFoodLevel);
if (res)
{
return true;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index ed18d2ab7..ab2dbc0cf 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -521,15 +521,15 @@ void cPlayer::Heal(int a_Health)
void cPlayer::SetFoodLevel(int a_FoodLevel)
{
- a_FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
+ int FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL));
- if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, a_FoodLevel))
+ if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, FoodLevel))
{
m_FoodSaturationLevel = 5.0;
return;
}
- m_FoodLevel = a_FoodLevel;
+ m_FoodLevel = FoodLevel;
SendHealth();
}
--
cgit v1.2.3
From f9f3f7eac59c8de2bcb3f878849d355d5b9e3c9a Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Mon, 30 Jun 2014 21:58:23 +0200
Subject: Fixed size_t printfing under MinGW.
---
src/Globals.h | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/Globals.h b/src/Globals.h
index c5768facf..0c11429bd 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -71,9 +71,24 @@
#define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
- #define SIZE_T_FMT "%zu"
- #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
- #define SIZE_T_FMT_HEX "%zx"
+ #if defined(_WIN32)
+ // We're compiling on MinGW, which uses an old MSVCRT library that has no support for size_t printfing.
+ // We need direct size formats:
+ #if defined(_WIN64)
+ #define SIZE_T_FMT "%I64u"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "I64u"
+ #define SIZE_T_FMT_HEX "%I64x"
+ #else
+ #define SIZE_T_FMT "%u"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "u"
+ #define SIZE_T_FMT_HEX "%x"
+ #endif
+ #else
+ // We're compiling on Linux, so we can use libc's size_t printf format:
+ #define SIZE_T_FMT "%zu"
+ #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
+ #define SIZE_T_FMT_HEX "%zx"
+ #endif
#define NORETURN __attribute((__noreturn__))
--
cgit v1.2.3
From 84272fb155d48f999441b7aaba9ca8b21584ad21 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Mon, 30 Jun 2014 22:21:07 +0100
Subject: Added dependecy of tolualib on lua
---
lib/tolua++/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt
index 44a4f1c6f..56ffc0dc1 100644
--- a/lib/tolua++/CMakeLists.txt
+++ b/lib/tolua++/CMakeLists.txt
@@ -46,6 +46,7 @@ file(GLOB BIN_SOURCE
add_executable(tolua ${BIN_SOURCE})
add_library(tolualib ${LIB_SOURCE})
+target_link_library(tolualib lua)
#m is the standard math librarys
if(UNIX)
--
cgit v1.2.3
From 0fb236bfe46782dc4e7c5b76db7b7c25671e3d66 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Mon, 30 Jun 2014 22:21:22 +0100
Subject: typo
---
lib/tolua++/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt
index 56ffc0dc1..12054323b 100644
--- a/lib/tolua++/CMakeLists.txt
+++ b/lib/tolua++/CMakeLists.txt
@@ -46,7 +46,7 @@ file(GLOB BIN_SOURCE
add_executable(tolua ${BIN_SOURCE})
add_library(tolualib ${LIB_SOURCE})
-target_link_library(tolualib lua)
+target_link_libraries(tolualib lua)
#m is the standard math librarys
if(UNIX)
--
cgit v1.2.3
From 4f60f5aef4517d6d3eaf2ea9f7aae30e6a97da25 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Tue, 1 Jul 2014 06:40:38 +0200
Subject: Fixed linking order under MinGW.
Ref.: #1044
---
lib/sqlite/CMakeLists.txt | 10 ++++++++--
src/CMakeLists.txt | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt
index 9add2280b..48bb5f15c 100644
--- a/lib/sqlite/CMakeLists.txt
+++ b/lib/sqlite/CMakeLists.txt
@@ -9,8 +9,14 @@ file(GLOB SOURCE
)
-# add headers to MSVC project files:
+# Lua is required as a DLL for LuaSQLite:
if (WIN32)
+ add_definitions(-DLUA_BUILD_AS_DLL)
+endif()
+
+
+# add headers to MSVC project files:
+if (MSVC)
file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS})
@@ -25,5 +31,5 @@ endif()
add_library(sqlite ${SOURCE})
if (UNIX)
- target_link_libraries(sqlite ${DYNAMIC_LOADER})
+ target_link_libraries(sqlite ${DYNAMIC_LOADER} lua)
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2f4d6ea13..b1b880b7b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -261,4 +261,4 @@ endif ()
if (WIN32)
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)
endif()
-target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib lua sqlite)
+target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib sqlite lua)
--
cgit v1.2.3
From 194678100a81134eeabb720d84fd987ef35946c6 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Tue, 1 Jul 2014 06:41:35 +0200
Subject: Ignore Code:::Blocks project files.
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 859ef28ea..4a319c5ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ cloc.xsl
## Eclipse
.cproject
.project
+*.cbp
# world inside source
ChunkWorx.ini
--
cgit v1.2.3
From eb8244f1c286ec33c30ba205eb5cebc1f2a0430d Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Tue, 1 Jul 2014 08:01:39 +0200
Subject: Proper sqlite dependency fix.
---
lib/sqlite/CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt
index 48bb5f15c..993dac146 100644
--- a/lib/sqlite/CMakeLists.txt
+++ b/lib/sqlite/CMakeLists.txt
@@ -29,7 +29,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
endif()
add_library(sqlite ${SOURCE})
+target_link_libraries(sqlite lua)
if (UNIX)
- target_link_libraries(sqlite ${DYNAMIC_LOADER} lua)
+ target_link_libraries(sqlite ${DYNAMIC_LOADER})
endif()
--
cgit v1.2.3
From 64f6ddf1e2171dd7713f454c792916257e770f98 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 1 Jul 2014 14:47:49 +0200
Subject: Fix server-crash with non-existing items.
---
src/Items/ItemHandler.cpp | 2 +-
src/UI/Window.cpp | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index a2fd4e3f8..0f56b2b90 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268];
cItemHandler * cItemHandler::GetItemHandler(int a_ItemType)
{
- if (a_ItemType < 0)
+ if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType)))
{
// Either nothing (-1), or bad value, both cases should return the air handler
if (a_ItemType < -1)
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 98a9a0cec..af3e3e45c 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -170,7 +170,13 @@ void cWindow::Clicked(
const cItem & a_ClickedItem
)
{
- cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
+ if (!IsValidItem(a_ClickedItem.m_ItemType) && !IsValidBlock(a_ClickedItem.m_ItemType))
+ {
+ LOGWARNING("%s: Player \"%s\" clicked to a non-existing item; ignoring click.", __FUNCTION__, a_Player.GetName().c_str());
+ return;
+ }
+
+ cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (a_WindowID != m_WindowID)
{
LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str());
--
cgit v1.2.3
From decdbab2e68427914f3d284acc0f6184719306c0 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Tue, 1 Jul 2014 15:23:29 +0200
Subject: LuaProxy compilation under MinGW.
---
lib/luaproxy/CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/luaproxy/CMakeLists.txt b/lib/luaproxy/CMakeLists.txt
index f115036e1..58ca87cd3 100644
--- a/lib/luaproxy/CMakeLists.txt
+++ b/lib/luaproxy/CMakeLists.txt
@@ -23,14 +23,17 @@ if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /NOENTRY /DEF:lua5.1.def /MANIFEST:NO")
+ elseif (MINGW)
+ # MinGW requires no further flags and has been tested
else()
- message ("This code has not been tested on your compiler. Please report your success or failure in the forum.")
+ message ("LuaProxy: This cmake code has not been tested on your compiler. Please report your success or failure in the forum.")
endif()
add_library(luaproxy SHARED "lua5.1.def" "Dummy.c")
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
set_target_properties(luaproxy PROPERTIES
OUTPUT_NAME "lua5.1"
+ PREFIX ""
)
target_link_libraries(luaproxy lua)
--
cgit v1.2.3
From 5a888f0a51ffbab6a6bd8ef24ff53ddf40a66ceb Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 1 Jul 2014 20:30:13 +0200
Subject: Change documentation
---
.../Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
index 4838573e5..5a6fc862a 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
@@ -5,18 +5,23 @@ return
CalledWhen = "Called before the player food level changed. Plugin may override / refuse.",
DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename
Desc = [[
- This hook is called just before the food level change.
- The food level is not yet changed, plugins may choose to override the new food level or refuse the change.
+ This hook is called before the food level changes.
+ The food level is not changed yet, plugins may choose
+ to override the new food level or refuse the change.
]],
Params =
{
- { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who change the food level." },
- { Name = "NewFoodLevel", Type = "number", Notes = "The new food level." },
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who changes the food level." },
+ { Name = "NewFoodLevel", Type = "number", Notes = "The new food level. You can override it." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
- server change the food level from the player. If the function returns true, no
+ server changes the food level of the player. If the function returns true, no
other callback is called for this event and the player's food level doesn't change.
]],
}, -- HOOK_PLAYER_FOOD_LEVEL_CHANGE
};
+
+
+
+
--
cgit v1.2.3
From 64e66674355c84c091564197dcbdf26806e61659 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 1 Jul 2014 20:34:50 +0200
Subject: Only fixes the server crash.
---
src/Items/ItemHandler.cpp | 2 +-
src/UI/Window.cpp | 6 ------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 0f56b2b90..423039cf4 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -63,7 +63,7 @@ cItemHandler * cItemHandler::m_ItemHandler[2268];
cItemHandler * cItemHandler::GetItemHandler(int a_ItemType)
{
- if ((a_ItemType < 0) || (a_ItemType >= ARRAYCOUNT(m_ItemHandler)) || (!IsValidBlock(a_ItemType) && !IsValidItem(a_ItemType)))
+ if ((a_ItemType < 0) || ((unsigned long)a_ItemType >= ARRAYCOUNT(m_ItemHandler)))
{
// Either nothing (-1), or bad value, both cases should return the air handler
if (a_ItemType < -1)
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index af3e3e45c..e465b701a 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -170,12 +170,6 @@ void cWindow::Clicked(
const cItem & a_ClickedItem
)
{
- if (!IsValidItem(a_ClickedItem.m_ItemType) && !IsValidBlock(a_ClickedItem.m_ItemType))
- {
- LOGWARNING("%s: Player \"%s\" clicked to a non-existing item; ignoring click.", __FUNCTION__, a_Player.GetName().c_str());
- return;
- }
-
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (a_WindowID != m_WindowID)
{
--
cgit v1.2.3
From 68007ab3e5aba33fb3a8e34c0301401aef594737 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 1 Jul 2014 20:42:23 +0200
Subject: Add doxy-comments.
---
src/Mobs/Sheep.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 41de7924f..36d7df826 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -14,7 +14,9 @@ class cSheep :
public:
- /** Use -1 for random color. */
+ /** The number is the color of the sheep.
+ 0-15 are the normal colors, if you type -1 the server
+ automatically chooses the right color for the sheep when spawned. */
cSheep(int a_Color = -1);
CLASS_PROTODEF(cSheep);
@@ -25,6 +27,7 @@ public:
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
+ /** Generates a random color for the sheep, like Mojang it does. */
static NIBBLETYPE GenerateNaturalRandomColor(void);
bool IsSheared(void) const { return m_IsSheared; }
--
cgit v1.2.3
From 0dfaad4123bc50202f97fc0e5d9fc5d3a9c8670c Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 1 Jul 2014 15:46:31 +0200
Subject: Fixed a possibly unused variable.
---
src/Bindings/PluginLua.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 96c5ccde7..97366cc4c 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -1714,7 +1714,7 @@ bool cPluginLua::CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer
ASSERT(a_FnRef != LUA_REFNIL);
cCSLock Lock(m_CriticalSection);
- bool res;
+ bool res = false;
m_LuaState.Call(a_FnRef, &a_Window, &a_Player, a_CanRefuse, cLuaState::Return, res);
return res;
}
--
cgit v1.2.3
From bb0e88fcf85846f5ff3cfb43d964657f14a1b6b7 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 1 Jul 2014 21:28:45 +0200
Subject: Initial codegen for LuaState_Call.inc.
---
src/Bindings/gen_LuaState_Call.lua | 196 +++++++++++++++++++++++++++++++++++++
1 file changed, 196 insertions(+)
create mode 100644 src/Bindings/gen_LuaState_Call.lua
diff --git a/src/Bindings/gen_LuaState_Call.lua b/src/Bindings/gen_LuaState_Call.lua
new file mode 100644
index 000000000..fb1797dc0
--- /dev/null
+++ b/src/Bindings/gen_LuaState_Call.lua
@@ -0,0 +1,196 @@
+
+-- gen_LuaState_Call.lua
+
+-- Generates the cLuaState::Call() function templates that are included from LuaState.h
+
+--[[
+The cLuaState::Call() family of functions provides a template-based system for calling any Lua function
+either by name or by reference with almost any number of parameters and return values. This is done by
+providing a number of overloads of the same name with variable number of template-type parameters. To
+separate the arguments from the return values, a special type of cLuaState::cRet is used.
+--]]
+
+
+
+
+print("Generating LuaState_Call.inc...")
+
+
+
+
+-- List of combinations (# params, # returns) to generate:
+local Combinations =
+{
+ -- no return values:
+ {0, 0},
+ {1, 0},
+ {2, 0},
+ {3, 0},
+ {4, 0},
+
+ -- 1 return value:
+ {0, 1},
+ {1, 1},
+ {2, 1},
+ {3, 1},
+ {4, 1},
+ {5, 1},
+ {6, 1},
+ {7, 1},
+ {8, 1},
+ {9, 1},
+ {10, 1},
+
+ -- 2 return values:
+ {0, 2},
+ {1, 2},
+ {2, 2},
+ {3, 2},
+ {4, 2},
+ {5, 2},
+ {6, 2},
+ {7, 2},
+ {8, 2},
+ {9, 2},
+
+ -- Special combinations:
+ {7, 3},
+ {8, 3},
+ {9, 5},
+}
+
+
+
+
+--- Writes a single overloaded function definition for the specified number of params and returns into f
+--[[
+The format for the generated function is this:
+/** Call the specified 3-param 2-return Lua function:
+Returns true if call succeeded, false if there was an error. */
+template
+bool Call(FnT a_Function, ParamT1 a_Param1, ParamT2 a_Param2, ParamT3 a_Param3, const cLuaState::cRet & a_RetMark, RetT1 & a_Ret1, RetT2 & a_Ret2)
+{
+ UNUSED(a_RetMark);
+ if (!PushFunction(a_Function))
+ {
+ return false;
+ }
+ Push(a_Param1);
+ Push(a_Param2);
+ Push(a_Param3);
+ if (!CallFunction(2))
+ {
+ return false;
+ }
+ GetStackValue(-2, a_Ret1);
+ GetStackValue(-1, a_Ret2);
+ lua_pop(m_LuaState, 2);
+ return true;
+}
+Note especially the negative numbers in GetStackValue() calls.
+--]]
+local function WriteOverload(f, a_NumParams, a_NumReturns)
+ -- Write the function doxy-comments:
+ f:write("/** Call the specified ", a_NumParams, "-param ", a_NumReturns, "-return Lua function:\n")
+ f:write("Returns true if call succeeded, false if there was an error. */\n")
+
+ -- Write the template <...> line:
+ f:write("template 0) then
+ for i = 1, a_NumReturns do
+ f:write(", typename RetT", i)
+ end
+ end
+ f:write(">\n")
+
+ -- Write the function signature:
+ f:write("bool Call(")
+ f:write("FnT a_Function")
+ for i = 1, a_NumParams do
+ f:write(", ParamT", i, " a_Param", i)
+ end
+ if (a_NumReturns > 0) then
+ f:write(", const cLuaState::cRet & a_RetMark")
+ for i = 1, a_NumReturns do
+ f:write(", RetT", i, " & a_Ret", i)
+ end
+ end
+ f:write(")\n")
+
+ -- Common code:
+ f:write("{\n")
+ if (a_NumReturns > 0) then
+ f:write("\tUNUSED(a_RetMark);\n")
+ end
+ f:write("\tif (!PushFunction(a_Function))\n")
+ f:write("\t{\n")
+ f:write("\t\treturn false;\n")
+ f:write("\t}\n")
+
+ -- Push the params:
+ for i = 1, a_NumParams do
+ f:write("\tPush(a_Param", i, ");\n")
+ end
+
+ -- Call the function:
+ f:write("\tif (!CallFunction(", a_NumReturns, "))\n")
+ f:write("\t{\n")
+ f:write("\t\treturn false;\n")
+ f:write("\t}\n")
+
+ -- Get the return values:
+ for i = 1, a_NumReturns do
+ f:write("\tGetStackValue(", -1 - a_NumReturns + i, ", a_Ret", i, ");\n")
+ end
+
+ -- Pop the returns off the stack, if needed:
+ if (a_NumReturns > 0) then
+ f:write("\tlua_pop(m_LuaState, ", a_NumReturns, ");\n")
+ end
+
+ -- Everything ok:
+ f:write("\treturn true;\n")
+ f:write("}\n")
+
+ -- Separate from the next function:
+ f:write("\n\n\n\n\n")
+end
+
+
+
+
+
+local f = assert(io.open("LuaState_Call.inc", "w"))
+
+-- Write file header:
+f:write([[
+// LuaState_Call.inc
+
+// This file is auto-generated by gen_LuaState_Call.lua
+// Make changes to the generator instead of to this file!
+
+// This file contains the various overloads for the cLuaState::Call() function
+// Each overload handles a different number of parameters / return values
+]])
+f:write("\n\n\n\n\n")
+
+-- Write out a template function for each overload:
+for _, combination in ipairs(Combinations) do
+ WriteOverload(f, combination[1], combination[2])
+end
+
+-- Close the generated file
+f:close()
+
+
+
+
+
+print("LuaState_Call.inc generated")
+
+
+
+
--
cgit v1.2.3
From b6d5d50b31e4fd0d34f42deb3aa51ebc8ae6f7f3 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 1 Jul 2014 22:19:14 +0200
Subject: Tolua generates LuaState_Call.inc file.
---
src/Bindings/.gitignore | 1 +
src/Bindings/LuaState.h | 629 +---------------------------------
src/Bindings/virtual_method_hooks.lua | 14 +
src/CMakeLists.txt | 11 +-
4 files changed, 31 insertions(+), 624 deletions(-)
diff --git a/src/Bindings/.gitignore b/src/Bindings/.gitignore
index af8aa76fa..0d00dd578 100644
--- a/src/Bindings/.gitignore
+++ b/src/Bindings/.gitignore
@@ -1 +1,2 @@
lua51.dll
+LuaState_Call.inc
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 066390e39..8aefa7c6b 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -9,10 +9,11 @@ Owned lua_State is created by calling Create() and the cLuaState automatically c
Or, lua_State can be attached by calling Attach(), the cLuaState doesn't close such a state
Attaching a state will automatically close an owned state.
-Calling a Lua function is done by pushing the function, either by PushFunction() or PushFunctionFromRegistry(),
-then pushing the arguments (PushString(), PushNumber(), PushUserData() etc.) and finally
-executing CallFunction(). cLuaState automatically keeps track of the number of arguments and the name of the
-function (for logging purposes), which makes the call less error-prone.
+Calling a Lua function is done internally by pushing the function using PushFunction(), then pushing the
+arguments and finally executing CallFunction(). cLuaState automatically keeps track of the number of
+arguments and the name of the function (for logging purposes). After the call the return values are read from
+the stack using GetStackValue(). All of this is wrapped in a templated function overloads cLuaState::Call(),
+which is generated automatically by gen_LuaState_Call.lua script file into the LuaState_Call.inc file.
Reference management is provided by the cLuaState::cRef class. This is used when you need to hold a reference to
any Lua object across several function calls; usually this is used for callbacks. The class is RAII-like, with
@@ -223,624 +224,8 @@ public:
void GetStackValue(int a_StackPos, double & a_Value);
- /** Call any 0-param 0-return Lua function in a single line: */
- template
- bool Call(FnT a_FnName)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- return CallFunction(0);
- }
-
- /** Call any 1-param 0-return Lua function in a single line: */
- template<
- typename FnT,
- typename ArgT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- return CallFunction(0);
- }
-
- /** Call any 2-param 0-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- return CallFunction(0);
- }
-
- /** Call any 3-param 0-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3)
- {
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- return CallFunction(0);
- }
-
- /** Call any 0-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename RetT1
- >
- bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 1-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- int InitialTop = lua_gettop(m_LuaState);
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- ASSERT(InitialTop == lua_gettop(m_LuaState));
- return true;
- }
-
- /** Call any 2-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 3-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 4-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 5-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 6-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 7-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 8-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename ArgT8, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 9-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- Push(a_Arg9);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 10-param 1-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6,
- typename ArgT7, typename ArgT8, typename ArgT9, typename ArgT10, typename RetT1
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- Push(a_Arg9);
- Push(a_Arg10);
- if (!CallFunction(1))
- {
- return false;
- }
- GetStackValue(-1, a_Ret1);
- lua_pop(m_LuaState, 1);
- return true;
- }
-
- /** Call any 1-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 2-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 3-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 4-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 5-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 6-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 7-param 2-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7,
- typename RetT1, typename RetT2
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- if (!CallFunction(2))
- {
- return false;
- }
- GetStackValue(-2, a_Ret1);
- GetStackValue(-1, a_Ret2);
- lua_pop(m_LuaState, 2);
- return true;
- }
-
- /** Call any 7-param 3-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7,
- typename RetT1, typename RetT2, typename RetT3
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- if (!CallFunction(3))
- {
- return false;
- }
- GetStackValue(-3, a_Ret1);
- GetStackValue(-2, a_Ret2);
- GetStackValue(-1, a_Ret3);
- lua_pop(m_LuaState, 3);
- return true;
- }
-
- /** Call any 8-param 3-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7, typename ArgT8,
- typename RetT1, typename RetT2, typename RetT3
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- if (!CallFunction(3))
- {
- return false;
- }
- GetStackValue(-3, a_Ret1);
- GetStackValue(-2, a_Ret2);
- GetStackValue(-1, a_Ret3);
- lua_pop(m_LuaState, 3);
- return true;
- }
-
- /** Call any 9-param 5-return Lua function in a single line: */
- template<
- typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5,
- typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9,
- typename RetT1, typename RetT2, typename RetT3, typename RetT4, typename RetT5
- >
- bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5)
- {
- UNUSED(a_Mark);
- if (!PushFunction(a_FnName))
- {
- return false;
- }
- Push(a_Arg1);
- Push(a_Arg2);
- Push(a_Arg3);
- Push(a_Arg4);
- Push(a_Arg5);
- Push(a_Arg6);
- Push(a_Arg7);
- Push(a_Arg8);
- Push(a_Arg9);
- if (!CallFunction(5))
- {
- return false;
- }
- GetStackValue(-5, a_Ret1);
- GetStackValue(-4, a_Ret2);
- GetStackValue(-3, a_Ret3);
- GetStackValue(-2, a_Ret4);
- GetStackValue(-1, a_Ret5);
- lua_pop(m_LuaState, 5);
- return true;
- }
+ // Include the cLuaState::Call() overload implementation that is generated by the gen_LuaState_Call.lua script:
+ #include "LuaState_Call.inc"
/** Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions */
diff --git a/src/Bindings/virtual_method_hooks.lua b/src/Bindings/virtual_method_hooks.lua
index c610d424f..8ad30bf78 100644
--- a/src/Bindings/virtual_method_hooks.lua
+++ b/src/Bindings/virtual_method_hooks.lua
@@ -3,6 +3,20 @@ local disable_virtual_hooks = true
local enable_pure_virtual = true
local default_private_access = false
+
+
+
+
+-- Code generators used by the build
+-- Note that these are not exactly needed for the bindings, but rather we
+-- misuse tolua's Lua engine to process files for us
+dofile("gen_LuaState_Call.lua")
+
+
+
+
+
+
local access = {public = 0, protected = 1, private = 2}
function preparse_hook(p)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b1b880b7b..c40e5edff 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,6 +12,7 @@ set(BINDING_DEPENDECIES
tolua
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
+ Bindings/gen_LuaState_Call.lua
Bindings/LuaFunctions.h
Bindings/LuaWindow.h
Bindings/Plugin.h
@@ -79,13 +80,19 @@ set(BINDING_DEPENDECIES
World.h
)
+# List all the files that are generated as part of the Bindings build process
+set (BINDING_OUTPUTS
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc
+)
+
include_directories(Bindings)
include_directories(.)
if (WIN32)
ADD_CUSTOM_COMMAND(
- # add any new generated bindings here
- OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
+ OUTPUT ${BINDING_OUTPUTS}
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
COMMAND copy /y ..\\..\\MCServer\\lua51.dll .
--
cgit v1.2.3
From 7177806d31a5c6df52a8439bee2f4d150fa0eb47 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Mon, 30 Jun 2014 22:37:26 +0200
Subject: Fixed printf formats for Win builds
---
src/OSSupport/Event.cpp | 6 +++---
src/OSSupport/IsThread.cpp | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp
index 6b8fccde2..72bce4c3c 100644
--- a/src/OSSupport/Event.cpp
+++ b/src/OSSupport/Event.cpp
@@ -18,7 +18,7 @@ cEvent::cEvent(void)
m_Event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (m_Event == NULL)
{
- LOGERROR("cEvent: cannot create event, GLE = %d. Aborting server.", GetLastError());
+ LOGERROR("cEvent: cannot create event, GLE = %u. Aborting server.", (unsigned)GetLastError());
abort();
}
#else // *nix
@@ -86,7 +86,7 @@ void cEvent::Wait(void)
DWORD res = WaitForSingleObject(m_Event, INFINITE);
if (res != WAIT_OBJECT_0)
{
- LOGWARN("cEvent: waiting for the event failed: %d, GLE = %d. Continuing, but server may be unstable.", res, GetLastError());
+ LOGWARN("cEvent: waiting for the event failed: %u, GLE = %u. Continuing, but server may be unstable.", (unsigned)res, (unsigned)GetLastError());
}
#else
int res = sem_wait(m_Event);
@@ -107,7 +107,7 @@ void cEvent::Set(void)
#ifdef _WIN32
if (!SetEvent(m_Event))
{
- LOGWARN("cEvent: Could not set cEvent: GLE = %d", GetLastError());
+ LOGWARN("cEvent: Could not set cEvent: GLE = %u", (unsigned)GetLastError());
}
#else
int res = sem_post(m_Event);
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp
index 67f336c97..1a436623a 100644
--- a/src/OSSupport/IsThread.cpp
+++ b/src/OSSupport/IsThread.cpp
@@ -90,7 +90,7 @@ bool cIsThread::Start(void)
m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &m_ThreadID);
if (m_Handle == NULL)
{
- LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError());
+ LOGERROR("ERROR: Could not create thread \"%s\", GLE = %u!", m_ThreadName.c_str(), (unsigned)GetLastError());
return false;
}
ResumeThread(m_Handle);
--
cgit v1.2.3
From 284c1c0514168e30338f2ad372b7e7f185dba0c4 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Tue, 1 Jul 2014 22:39:37 +0100
Subject: Vector clamping fixes
Thank you, @madmaxoft.
---
src/Entities/ArrowEntity.cpp | 12 ++++++++----
src/Vector3.h | 33 ++++++++++++++++-----------------
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 2d6683f0a..7e96a666d 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -69,14 +69,18 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
Vector3d Hit = a_HitPos;
- Vector3d SinkMovement = GetSpeed() / 800;
- SinkMovement.Clamp(0.001, 0.001, 0.001, 0.05, 0.05, 0.05);
+ Vector3d SinkMovement = GetSpeed() / 800; // Base value for arrow penetration
+ SinkMovement = Clamp( // Adjust the movement so that fast arrows don't go through blocks (though in reality they would, in addition to exploding into fragments :P)
+ SinkMovement,
+ (SinkMovement * 0.001) / SinkMovement.Length(),
+ (SinkMovement * 0.05) / SinkMovement.Length()
+ );
Hit += SinkMovement; // Make arrow sink into block a little
super::OnHitSolidBlock(Hit, a_HitFace);
- Hit.Floor();
+ Vector3i BlockHit = Hit.Floor();
- int X = Hit.x, Y = Hit.y, Z = Hit.z;
+ int X = BlockHit.x, Y = BlockHit.y, Z = BlockHit.z;
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
diff --git a/src/Vector3.h b/src/Vector3.h
index b5ddc705a..faf7fe43c 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -135,19 +135,13 @@ public:
}
/** Runs each value of the vector through std::floor() */
- inline void Floor(void)
+ inline Vector3 Floor(void) const
{
- x = (T)floor(x);
- y = (T)floor(y);
- z = (T)floor(z);
- }
-
- /** Clamps each value in the vector to within a specified range */
- inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ)
- {
- x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x));
- y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y));
- z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z));
+ return Vector3(
+ (T)floor(x),
+ (T)floor(y),
+ (T)floor(z)
+ );
}
// tolua_end
@@ -162,6 +156,16 @@ public:
return Equals(a_Rhs);
}
+ inline bool operator > (const Vector3 & a_Rhs) const
+ {
+ return (SqrLength() > a_Rhs.SqrLength());
+ }
+
+ inline bool operator < (const Vector3 & a_Rhs) const
+ {
+ return (SqrLength() < a_Rhs.SqrLength());
+ }
+
inline void operator += (const Vector3 & a_Rhs)
{
x += a_Rhs.x;
@@ -305,11 +309,6 @@ protected:
return (a_Value < 0) ? -a_Value : a_Value;
}
- /** Clamp X to the specified range. */
- T Clamp(T a_Value, T a_Min, T a_Max)
- {
- return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value);
- }
};
// tolua_end
--
cgit v1.2.3
From 4a9002045b86406ffd4bb16f67d33ae4060e6bc7 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Wed, 2 Jul 2014 14:46:00 +0200
Subject: Removed foodlevel-change possibility. Plugins can cancel the event
and use cPlayer:SetFoodLevel()
---
src/Bindings/Plugin.h | 2 +-
src/Bindings/PluginLua.cpp | 4 ++--
src/Bindings/PluginLua.h | 2 +-
src/Bindings/PluginManager.cpp | 2 +-
src/Bindings/PluginManager.h | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 254209bd2..8ba20c026 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -72,7 +72,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) = 0;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0;
- virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) = 0;
+ virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0;
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;
virtual bool OnPlayerMoved (cPlayer & a_Player) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 2d485a117..542ae3e56 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -715,14 +715,14 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player)
-bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel)
+bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FOOD_LEVEL_CHANGE];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res, a_NewFoodLevel);
+ m_LuaState.Call((int)(**itr), &a_Player, a_NewFoodLevel, cLuaState::Return, res);
if (res)
{
return true;
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index cf244f33d..9c9de95c6 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -95,7 +95,7 @@ public:
virtual bool OnPlayerEating (cPlayer & a_Player) override;
virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override;
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override;
- virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel) override;
+ virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override;
virtual bool OnPlayerJoined (cPlayer & a_Player) override;
virtual bool OnPlayerMoved (cPlayer & a_Player) override;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 936c6b8a8..3cb8c99a1 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -695,7 +695,7 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
-bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int & a_NewFoodLevel)
+bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
{
FIND_HOOK(HOOK_PLAYER_FOOD_LEVEL_CHANGE);
VERIFY_HOOK;
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 560a5c1d3..72cedfae1 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -189,7 +189,7 @@ public: // tolua_export
bool CallHookPlayerEating (cPlayer & a_Player);
bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward);
bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
- bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int & a_NewFoodLevel);
+ bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
bool CallHookPlayerMoving (cPlayer & a_Player);
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
--
cgit v1.2.3
From 835d00428c2af43050fa248ab988c431ec1be152 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Wed, 2 Jul 2014 14:49:08 +0200
Subject: Update documentation
---
MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
index 5a6fc862a..53637d5f1 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFoodLevelChange.lua
@@ -2,17 +2,17 @@ return
{
HOOK_PLAYER_FOOD_LEVEL_CHANGE =
{
- CalledWhen = "Called before the player food level changed. Plugin may override / refuse.",
+ CalledWhen = "Called before the player food level changed. Plugin may override",
DefaultFnName = "OnPlayerFoodLevelChange", -- also used as pagename
Desc = [[
This hook is called before the food level changes.
The food level is not changed yet, plugins may choose
- to override the new food level or refuse the change.
+ to refuse the change.
]],
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who changes the food level." },
- { Name = "NewFoodLevel", Type = "number", Notes = "The new food level. You can override it." },
+ { Name = "NewFoodLevel", Type = "number", Notes = "The new food level." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called. Afterwards, the
--
cgit v1.2.3
From 1c16862ae522b2124e7fd3b1a2dce7807f33b503 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Wed, 2 Jul 2014 16:30:13 +0200
Subject: CMake: Use cmake for file-copying.
This should enable MSYS builds.
---
src/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b1b880b7b..c905ebebe 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -88,7 +88,7 @@ if (WIN32)
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
- COMMAND copy /y ..\\..\\MCServer\\lua51.dll .
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ..\\..\\MCServer\\lua51.dll .\\lua51.dll
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
--
cgit v1.2.3
From 19caba5125e457a9663102989ea717898e3c2827 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 2 Jul 2014 18:46:00 +0100
Subject: Redstone simulator is alerted to lever unpowering
* Fixed the "fix" that broke the fix for #535, thereby fixing said issue
* Fixed #535
---
src/Blocks/BlockButton.h | 1 +
src/Blocks/BlockLever.h | 1 +
src/Blocks/WorldInterface.h | 3 +++
src/World.h | 2 +-
4 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 7d9af207d..ada7d58f7 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -23,6 +23,7 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
// Queue a button reset (unpress)
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index afe43abf8..4e745d413 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -23,6 +23,7 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
+ a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h
index 650a216c0..251b28d03 100644
--- a/src/Blocks/WorldInterface.h
+++ b/src/Blocks/WorldInterface.h
@@ -46,4 +46,7 @@ public:
virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0;
+ /** Wakes up the simulators for the specified block */
+ virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
+
};
diff --git a/src/World.h b/src/World.h
index 692d5a497..32e64c8e0 100644
--- a/src/World.h
+++ b/src/World.h
@@ -486,7 +486,7 @@ public:
double GetSpawnZ(void) const { return m_SpawnZ; }
/** Wakes up the simulators for the specified block */
- void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ);
+ virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override;
/** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
--
cgit v1.2.3
From c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 2 Jul 2014 18:46:13 +0100
Subject: Fixed player teleport food drain
---
src/Entities/Player.cpp | 10 +++++++++-
src/Entities/Player.h | 5 +++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index daf1ef2cc..66791eb7c 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -71,6 +71,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_FloaterID(-1)
, m_Team(NULL)
, m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL)
+ , m_bIsTeleporting(false)
{
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
@@ -225,7 +226,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
SendExperience();
}
- if (GetPosition() != m_LastPos) // Change in position from last tick?
+ if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick?
{
// Apply food exhaustion from movement:
ApplyFoodExhaustionFromMovement();
@@ -970,6 +971,7 @@ void cPlayer::Respawn(void)
// Reset food level:
m_FoodLevel = MAX_FOOD_LEVEL;
m_FoodSaturationLevel = 5;
+ m_FoodExhaustionLevel = 0;
// Reset Experience
m_CurrentXp = 0;
@@ -1226,6 +1228,7 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
SetPosition(a_PosX, a_PosY, a_PosZ);
m_LastGroundHeight = (float)a_PosY;
m_LastJumpHeight = (float)a_PosY;
+ m_bIsTeleporting = true;
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
m_ClientHandle->SendPlayerMoveLook();
@@ -2079,6 +2082,11 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
{
return;
}
+ if (m_bIsTeleporting)
+ {
+ m_bIsTeleporting = false;
+ return;
+ }
// If riding anything, apply no food exhaustion
if (m_AttachedTo != NULL)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 2f7957f16..9e443b468 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -546,6 +546,11 @@ protected:
Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */
unsigned int m_TicksUntilNextSave;
+ /** Flag used by food handling system to determine whether a teleport has just happened
+ Will not apply food penalties if found to be true; will set to false after processing
+ */
+ bool m_bIsTeleporting;
+
} ; // tolua_export
--
cgit v1.2.3
From abb49d3f338de4078177d1b95e3ed8d195119b50 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 2 Jul 2014 18:51:37 +0100
Subject: Suggestion
---
src/Entities/Player.cpp | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index aeeea3d07..f888af642 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1787,20 +1787,20 @@ bool cPlayer::SaveToDisk()
cEnderChestEntity::SaveToJson(JSON_EnderChestInventory, m_EnderChestContents);
Json::Value root;
- root["position"] = JSON_PlayerPosition;
- root["rotation"] = JSON_PlayerRotation;
- root["inventory"] = JSON_Inventory;
+ root["position"] = JSON_PlayerPosition;
+ root["rotation"] = JSON_PlayerRotation;
+ root["inventory"] = JSON_Inventory;
root["enderchestinventory"] = JSON_EnderChestInventory;
- root["health"] = m_Health;
- root["xpTotal"] = m_LifetimeTotalXp;
- root["xpCurrent"] = m_CurrentXp;
- root["air"] = m_AirLevel;
- root["food"] = m_FoodLevel;
- root["foodSaturation"] = m_FoodSaturationLevel;
- root["foodTickTimer"] = m_FoodTickTimer;
- root["foodExhaustion"] = m_FoodExhaustionLevel;
- root["world"] = GetWorld()->GetName();
- root["isflying"] = IsFlying();
+ root["health"] = m_Health;
+ root["xpTotal"] = m_LifetimeTotalXp;
+ root["xpCurrent"] = m_CurrentXp;
+ root["air"] = m_AirLevel;
+ root["food"] = m_FoodLevel;
+ root["foodSaturation"] = m_FoodSaturationLevel;
+ root["foodTickTimer"] = m_FoodTickTimer;
+ root["foodExhaustion"] = m_FoodExhaustionLevel;
+ root["world"] = GetWorld()->GetName();
+ root["isflying"] = IsFlying();
if (m_GameMode == GetWorld()->GetGameMode())
{
--
cgit v1.2.3
From 89a26cc786f3673cf7b5a100300d8aa595735cc3 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 2 Jul 2014 21:07:34 +0100
Subject: Suggestions
---
src/Entities/ArrowEntity.cpp | 16 ++++++++--------
src/Entities/ArrowEntity.h | 6 ++++++
src/WorldStorage/NBTChunkSerializer.cpp | 17 ++++++++---------
src/WorldStorage/WSSAnvil.cpp | 11 +++++++++--
4 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 7e96a666d..c039b0b3c 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -67,15 +67,15 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
-{
+{
+ if (GetSpeed().SqrLength() == 0)
+ {
+ SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later
+ }
+
Vector3d Hit = a_HitPos;
- Vector3d SinkMovement = GetSpeed() / 800; // Base value for arrow penetration
- SinkMovement = Clamp( // Adjust the movement so that fast arrows don't go through blocks (though in reality they would, in addition to exploding into fragments :P)
- SinkMovement,
- (SinkMovement * 0.001) / SinkMovement.Length(),
- (SinkMovement * 0.05) / SinkMovement.Length()
- );
- Hit += SinkMovement; // Make arrow sink into block a little
+ Vector3d SinkMovement = (GetSpeed() / 800);
+ Hit += (SinkMovement * 0.01) / SinkMovement.Length(); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside)
super::OnHitSolidBlock(Hit, a_HitFace);
Vector3i BlockHit = Hit.Floor();
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 1fe3032ee..99b7bae31 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -58,8 +58,14 @@ public:
/// Sets the IsCritical flag
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
+
+ /** Gets the block arrow is in */
+ Vector3i GetBlockHit(void) const { return m_HitBlockPos; }
// tolua_end
+
+ /** Sets the block arrow is in */
+ void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; }
protected:
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 8294d4a00..e49042ff7 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -589,20 +589,19 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.BeginCompound("");
AddBasicEntity(a_Projectile, a_Projectile->GetMCAClassName());
Vector3d Pos = a_Projectile->GetPosition();
- m_Writer.AddShort("xTile", (Int16)floor(Pos.x));
- m_Writer.AddShort("yTile", (Int16)floor(Pos.y));
- m_Writer.AddShort("zTile", (Int16)floor(Pos.z));
- m_Writer.AddShort("inTile", 0); // TODO: Query the block type
- m_Writer.AddShort("shake", 0); // TODO: Any shake?
- m_Writer.AddByte ("inGround", a_Projectile->IsInGround() ? 1 : 0);
+ m_Writer.AddByte("inGround", a_Projectile->IsInGround() ? 1 : 0);
switch (a_Projectile->GetProjectileKind())
{
case cProjectileEntity::pkArrow:
{
- m_Writer.AddByte("inData", 0); // TODO: Query the block meta (is it needed?)
- m_Writer.AddByte("pickup", ((cArrowEntity *)a_Projectile)->GetPickupState());
- m_Writer.AddDouble("damage", ((cArrowEntity *)a_Projectile)->GetDamageCoeff());
+ cArrowEntity * Arrow = (cArrowEntity *)a_Projectile;
+
+ m_Writer.AddInt("xTile", (Int16)Arrow->GetBlockHit().x);
+ m_Writer.AddInt("yTile", (Int16)Arrow->GetBlockHit().y);
+ m_Writer.AddInt("zTile", (Int16)Arrow->GetBlockHit().z);
+ m_Writer.AddByte("pickup", Arrow->GetPickupState());
+ m_Writer.AddDouble("damage", Arrow->GetDamageCoeff());
break;
}
case cProjectileEntity::pkGhastFireball:
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 0f84a0eb1..1e9ce80cc 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1656,6 +1656,15 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
Arrow->SetDamageCoeff(a_NBT.GetDouble(DamageIdx));
}
+ // Load block hit:
+ int InBlockXIdx = a_NBT.FindChildByName(a_TagIdx, "xTile");
+ int InBlockYIdx = a_NBT.FindChildByName(a_TagIdx, "yTile");
+ int InBlockZIdx = a_NBT.FindChildByName(a_TagIdx, "zTile");
+ if ((InBlockXIdx > 0) && (InBlockYIdx > 0) && (InBlockZIdx > 0))
+ {
+ Arrow->SetBlockHit(Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx)));
+ }
+
// Store the new arrow in the entities list:
a_Entities.push_back(Arrow.release());
}
@@ -2481,8 +2490,6 @@ bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cP
}
a_Entity.SetIsInGround(IsInGround);
- // TODO: Load inTile, TileCoords
-
return true;
}
--
cgit v1.2.3
From 6f0a538385ee3fce2fa3e3ffd11bf23dd8db278c Mon Sep 17 00:00:00 2001
From: archshift
Date: Wed, 2 Jul 2014 21:19:09 -0700
Subject: SetFlags.cmake: don't use ${} expansion on if STREQUAL
See http://stackoverflow.com/questions/19982340/cmake-compare-to-empty-string-with-strequal-failed
---
SetFlags.cmake | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 339174e5c..bf467ca01 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -28,7 +28,8 @@ endmacro()
macro(set_flags)
# Add coverage processing, if requested:
if (NOT MSVC)
- if (${CMAKE_BUILD_TYPE} STREQUAL "COVERAGE")
+
+ if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE")
message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
--
cgit v1.2.3
From 78dd02f0c7195d046bfd4c50f96c12d95ad92ae0 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 3 Jul 2014 10:11:46 +0200
Subject: CMake: Changed slash format to support MSYS.
Ref.: #1044
---
src/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c905ebebe..55f3028ef 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -88,7 +88,7 @@ if (WIN32)
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ..\\..\\MCServer\\lua51.dll .\\lua51.dll
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
--
cgit v1.2.3
From 2dbed03cbce873d8a6582bfdc5c4b826b6e7eade Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 3 Jul 2014 17:49:21 +0200
Subject: Changed OnWeatherChanging hook to always read the returned weather.
Ref.: http://forum.mc-server.org/showthread.php?tid=1512
---
src/Bindings/LuaState.cpp | 12 ++++++++++++
src/Bindings/LuaState.h | 5 +++++
src/Bindings/PluginLua.cpp | 5 +----
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 7a5ed1425..32638df96 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -811,6 +811,18 @@ void cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
+{
+ if (lua_isnumber(m_LuaState, a_StackPos))
+ {
+ a_ReturnedVal = (eWeather)Clamp((int)tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal), (int)wSunny, (int)wThunderstorm);
+ }
+}
+
+
+
+
+
bool cLuaState::CallFunction(int a_NumResults)
{
ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 066390e39..723193ae7 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -30,6 +30,7 @@ extern "C"
}
#include "../Vector3.h"
+#include "../Defines.h"
@@ -222,6 +223,10 @@ public:
/** Retrieve value at a_StackPos, if it is a valid number. If not, a_Value is unchanged */
void GetStackValue(int a_StackPos, double & a_Value);
+ /** Retrieve value at a_StackPos, if it is a valid number, converting and clamping it to eWeather.
+ If not, a_Value is unchanged. */
+ void GetStackValue(int a_StackPos, eWeather & a_Value);
+
/** Call any 0-param 0-return Lua function in a single line: */
template
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 344031995..104380ea4 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -1347,18 +1347,15 @@ bool cPluginLua::OnWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
- int NewWeather = a_NewWeather;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WEATHER_CHANGING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_World, NewWeather, cLuaState::Return, res, NewWeather);
+ m_LuaState.Call((int)(**itr), &a_World, a_NewWeather, cLuaState::Return, res, a_NewWeather);
if (res)
{
- a_NewWeather = (eWeather)NewWeather;
return true;
}
}
- a_NewWeather = (eWeather)NewWeather;
return false;
}
--
cgit v1.2.3
From 20afd5d70ee61e969f4015f851c1d8f04cd02215 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 3 Jul 2014 17:53:57 +0200
Subject: APIDump: Updated OnWeatherChanging docs after latest code changes.
---
MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua
index d36164e8e..bb809af11 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua
@@ -6,7 +6,7 @@ return
DefaultFnName = "OnWeatherChanging", -- also used as pagename
Desc = [[
This hook is called when the current weather has expired and a new weather is selected. Plugins may
- override the new weather setting.
+ override the new weather being set.
The new weather setting is sent to the clients only after this hook has been processed.
@@ -19,9 +19,12 @@ return
{ Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" },
},
Returns = [[
- If the function returns false or no value, the server calls other plugins' callbacks and finally
- sets the weather. If the function returns true, the server takes the second returned value (wSunny
- by default) and sets it as the new weather. No other plugins' callbacks are called in this case.
+ The hook handler can return up to two values. If the first value is false or not present, the server
+ calls other plugins' callbacks and finally sets the weather. If it is true, the server doesn't call any
+ more callbacks for this hook. The second value returned is used as the new weather. If no value is
+ given, the weather from the parameters is used as the weather. Returning false as the first value and a
+ specific weather constant as the second value makes the server call the rest of the hook handlers with
+ the new weather value.
]],
}, -- HOOK_WEATHER_CHANGING
}
--
cgit v1.2.3
From 632e8680b181477ebf6713a593cc69d0193a425b Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 4 Jul 2014 11:50:50 +0200
Subject: Removed world-saving log messages.
Ref.: http://forum.mc-server.org/showthread.php?tid=1518
---
src/World.cpp | 2 --
src/WorldStorage/WorldStorage.cpp | 35 +++++------------------------------
src/WorldStorage/WorldStorage.h | 3 ---
3 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/src/World.cpp b/src/World.cpp
index bd7694e96..48c3448a3 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2776,10 +2776,8 @@ bool cWorld::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunk
void cWorld::SaveAllChunks(void)
{
- LOGINFO("Saving all chunks...");
m_LastSave = m_WorldAge;
m_ChunkMap->SaveAllChunks();
- m_Storage.QueueSavedMessage();
}
diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp
index 6867ad5bc..d3f35384b 100644
--- a/src/WorldStorage/WorldStorage.cpp
+++ b/src/WorldStorage/WorldStorage.cpp
@@ -17,13 +17,6 @@
-/// If a chunk with this Y coord is de-queued, it is a signal to emit the saved-all message (cWorldStorage::QueueSavedMessage())
-#define CHUNK_Y_MESSAGE 2
-
-
-
-
-
/// Example storage schema - forgets all chunks ;)
class cWSSForgetful :
public cWSSchema
@@ -168,17 +161,6 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
-void cWorldStorage::QueueSavedMessage(void)
-{
- // Pushes a special coord pair into the queue, signalizing a message instead
- m_SaveQueue.EnqueueItem(cChunkCoords(0, CHUNK_Y_MESSAGE, 0));
- m_Event.Set();
-}
-
-
-
-
-
void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true));
@@ -286,19 +268,12 @@ bool cWorldStorage::SaveOneChunk(void)
{
cChunkCoords ToSave(0, 0, 0);
bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave);
- if(ShouldSave) {
- if (ToSave.m_ChunkY == CHUNK_Y_MESSAGE)
- {
- LOGINFO("Saved all chunks in world %s", m_World->GetName().c_str());
- return ShouldSave;
- }
- if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ))
+ if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ))
+ {
+ m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ);
+ if (m_SaveSchema->SaveChunk(ToSave))
{
- m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ);
- if (m_SaveSchema->SaveChunk(ToSave))
- {
- m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ);
- }
+ m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ);
}
}
return ShouldSave;
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index bb189b6c9..1204b4310 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -67,9 +67,6 @@ public:
void QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate); // Queues the chunk for loading; if not loaded, the chunk will be generated if a_Generate is true
void QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
- /// Signals that a message should be output to the console when all the chunks have been saved
- void QueueSavedMessage(void);
-
/// Loads the chunk specified; returns true on success, false on failure
bool LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
--
cgit v1.2.3
From a0d2df93272a6108f8c568e1eed665a1da5cb7ed Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 10:55:09 +0100
Subject: Tailored death messages
---
src/Bindings/Plugin.h | 2 +-
src/Bindings/PluginLua.cpp | 4 ++--
src/Bindings/PluginLua.h | 2 +-
src/Bindings/PluginManager.cpp | 4 ++--
src/Bindings/PluginManager.h | 2 +-
src/Entities/EnderCrystal.cpp | 4 ++--
src/Entities/EnderCrystal.h | 2 +-
src/Entities/Entity.cpp | 8 ++++----
src/Entities/Entity.h | 2 +-
src/Entities/ItemFrame.cpp | 6 +++---
src/Entities/ItemFrame.h | 2 +-
src/Entities/Painting.h | 4 ++--
src/Entities/Player.cpp | 35 ++++++++++++++++++++++++++++-------
src/Entities/Player.h | 2 +-
src/Mobs/Monster.cpp | 6 +++---
src/Mobs/Monster.h | 2 +-
src/Mobs/Wither.cpp | 4 ++--
src/Mobs/Wither.h | 2 +-
src/Mobs/ZombiePigman.cpp | 6 +++---
src/Mobs/ZombiePigman.h | 2 +-
20 files changed, 61 insertions(+), 40 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 8ba20c026..160e83bde 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -63,7 +63,7 @@ public:
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
- virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) = 0;
+ virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) = 0;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 344031995..078e48111 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -575,14 +575,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper,
-bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer)
+bool cPluginLua::OnKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Victim, &a_TDI, cLuaState::Return, res);
if (res)
{
return true;
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 9c9de95c6..d1514a731 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -86,7 +86,7 @@ public:
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
- virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) override;
+ virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) override;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 3cb8c99a1..1ebe8dd68 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -562,14 +562,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
-bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
+bool cPluginManager::CallHookKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI)
{
FIND_HOOK(HOOK_KILLING);
VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnKilling(a_Victim, a_Killer))
+ if ((*itr)->OnKilling(a_Victim, a_TDI))
{
return true;
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 72cedfae1..7d63626bd 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -180,7 +180,7 @@ public: // tolua_export
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
- bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer);
+ bool CallHookKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI);
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp
index a640b236c..bf86a6c42 100644
--- a/src/Entities/EnderCrystal.cpp
+++ b/src/Entities/EnderCrystal.cpp
@@ -42,9 +42,9 @@ void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk)
-void cEnderCrystal::KilledBy(cEntity * a_Killer)
+void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index 5b86df987..30211de13 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -24,7 +24,7 @@ private:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
}; // tolua_export
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 2b256e766..56ef22280 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -368,7 +368,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (m_Health <= 0)
{
- KilledBy(a_TDI.Attacker);
+ KilledBy(a_TDI);
if (a_TDI.Attacker != NULL)
{
@@ -524,11 +524,11 @@ double cEntity::GetKnockbackAmountAgainst(const cEntity & a_Receiver)
-void cEntity::KilledBy(cEntity * a_Killer)
+void cEntity::KilledBy(TakeDamageInfo & a_TDI)
{
m_Health = 0;
- cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_Killer);
+ cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI);
if (m_Health > 0)
{
@@ -538,7 +538,7 @@ void cEntity::KilledBy(cEntity * a_Killer)
// Drop loot:
cItems Drops;
- GetDrops(Drops, a_Killer);
+ GetDrops(Drops, a_TDI.Attacker);
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
m_World->BroadcastEntityStatus(*this, esGenericDead);
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 2df66e353..e34cf55d2 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -309,7 +309,7 @@ public:
virtual cItem GetEquippedBoots(void) const { return cItem(); }
/// Called when the health drops below zero. a_Killer may be NULL (environmental damage)
- virtual void KilledBy(cEntity * a_Killer);
+ virtual void KilledBy(TakeDamageInfo & a_TDI);
/// Called when the entity kills another entity
virtual void Killed(cEntity * a_Victim) {}
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index 7bc7bda8d..4cd707faa 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -51,17 +51,17 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
-void cItemFrame::KilledBy(cEntity * a_Killer)
+void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
{
if (m_Item.IsEmpty())
{
SetHealth(0);
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
Destroy();
return;
}
- if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
+ if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative())
{
cItems Item;
Item.push_back(m_Item);
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index 6577e7d94..9261e52cc 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -35,7 +35,7 @@ public:
private:
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
cItem m_Item;
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index c1024bd1b..30af6d412 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -26,9 +26,9 @@ private:
virtual void SpawnOn(cClientHandle & a_Client) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
- virtual void KilledBy(cEntity * a_Killer) override
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
Destroy();
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index dbb8cd26c..3fffc4643 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -889,9 +889,9 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cPlayer::KilledBy(cEntity * a_Killer)
+void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
if (m_Health > 0)
{
@@ -915,19 +915,40 @@ void cPlayer::KilledBy(cEntity * a_Killer)
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place !
- if (a_Killer == NULL)
+ if (a_TDI.Attacker == NULL)
{
- GetWorld()->BroadcastChatDeath(Printf("%s was killed by environmental damage", GetName().c_str()));
+ AString DamageText;
+ switch (a_TDI.DamageType)
+ {
+ case dtRangedAttack: DamageText = "was shot"; break;
+ case dtLightning: DamageText = "was plasmified by lightining"; break;
+ case dtFalling: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "fell to death" : "hit the ground too hard"; break;
+ case dtDrowning: DamageText = "drowned"; break;
+ case dtSuffocating: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "git merge'd into a block" : "fused with a block"; break;
+ case dtStarving: DamageText = "forgot the importance of food"; break;
+ case dtCactusContact: DamageText = "was impaled on a cactus"; break;
+ case dtLavaContact: DamageText = "was melted by lava"; break;
+ case dtPoisoning: DamageText = "died from septicaemia"; break;
+ case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break;
+ case dtFireContact: DamageText = "burnt themselves to death"; break;
+ case dtInVoid: DamageText = "somehow fell out of the world"; break;
+ case dtPotionOfHarming: DamageText = "was magicked to death"; break;
+ case dtEnderPearl: DamageText = "misused an ender pearl"; break;
+ case dtAdmin: DamageText = "was administrator'd"; break;
+ case dtExplosion: DamageText = "blew up"; break;
+ default: DamageText = "died, somehow; we've no idea how though"; break;
+ }
+ GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));
}
- else if (a_Killer->IsPlayer())
+ else if (a_TDI.Attacker->IsPlayer())
{
- cPlayer * Killer = (cPlayer *)a_Killer;
+ cPlayer * Killer = (cPlayer *)a_TDI.Attacker;
GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()));
}
else
{
- AString KillerClass = a_Killer->GetClass();
+ AString KillerClass = a_TDI.Attacker->GetClass();
KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index f247ac2f9..48bf00fb9 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -323,7 +323,7 @@ public:
/** Aborts the current eating operation */
void AbortEating(void);
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void Killed(cEntity * a_Victim) override;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 5843ca5a6..6ef90d489 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -492,9 +492,9 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cMonster::KilledBy(cEntity * a_Killer)
+void cMonster::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
if (m_SoundHurt != "")
{
m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
@@ -558,7 +558,7 @@ void cMonster::KilledBy(cEntity * a_Killer)
break;
}
}
- if ((a_Killer != NULL) && (!IsBaby()))
+ if ((a_TDI.Attacker != NULL) && (!IsBaby()))
{
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
}
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 7d7e90eb2..8c9f006d3 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -90,7 +90,7 @@ public:
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void MoveToPosition(const Vector3f & a_Position);
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index da4cc7765..578b47995 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -103,9 +103,9 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cWither::KilledBy(cEntity * a_Killer)
+void cWither::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
class cPlayerCallback : public cPlayerListCallback
{
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 03a320788..7d76f70f5 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -29,7 +29,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
private:
diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp
index c9d94face..05350f877 100644
--- a/src/Mobs/ZombiePigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -37,11 +37,11 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cZombiePigman::KilledBy(cEntity * a_Killer)
+void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI)
{
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
- if ((a_Killer != NULL) && (a_Killer->IsPlayer()))
+ if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
{
// TODO: Anger all nearby zombie pigmen
// TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index ab3cebf6d..a2ebc87cb 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cZombiePigman);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
} ;
--
cgit v1.2.3
From ec2f576de69f2a6e73abb1aeadb173c0b2e12131 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 2 Jul 2014 22:25:18 +0100
Subject: Fixed c1deda5d8f01811efa5094e9375166acb69d50ed
I keep on breaking stuff :P
---
src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 866a5b65a..5af9a295d 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -1700,7 +1700,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc
{
continue;
}
- a_PowerLevel = itr->a_PowerLevel;
+ a_PowerLevel = std::max(itr->a_PowerLevel , a_PowerLevel); // Get the highest power level (a_PowerLevel is initialised already and there CAN be multiple levels for one block)
}
for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list
@@ -1709,7 +1709,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc
{
continue;
}
- a_PowerLevel = itr->a_PowerLevel;
+ a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel);
}
return (a_PowerLevel != 0); // Answer the inital question: is the wire powered?
--
cgit v1.2.3
From f6350662414044896e7971dcc792c83d5eaddbce Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 12:50:40 +0100
Subject: Eps comparison
---
src/Entities/ArrowEntity.cpp | 2 +-
src/Entities/ArrowEntity.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index c039b0b3c..1d539679c 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -68,7 +68,7 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- if (GetSpeed().SqrLength() == 0)
+ if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001))
{
SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later
}
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 99b7bae31..76cb24449 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -64,7 +64,7 @@ public:
// tolua_end
- /** Sets the block arrow is in */
+ /** Sets the block arrow is in. To be used by the MCA loader only! */
void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; }
protected:
--
cgit v1.2.3
From aa81a3ff3e2d9c66e699e244cab0b624167a9127 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Fri, 4 Jul 2014 14:29:19 +0200
Subject: Fixed ExecuteCommand description.
---
MCServer/Plugins/APIDump/APIDesc.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index fe38d94c7..412fcc405 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1872,7 +1872,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." },
DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." },
- ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." },
+ ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns a {{cPluginManager#CommandResult|CommandResult}} value." },
FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" },
ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature: function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
--
cgit v1.2.3
From 41747f05002821901afc05dd25eb9567eac56eb6 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Fri, 4 Jul 2014 15:07:41 +0200
Subject: Moved sending error messages to cPluginManager:CallHookChat
---
src/Bindings/PluginManager.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 2cd514211..8a6ac26fa 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -257,9 +257,13 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
- if (HandleCommand(a_Player, a_Message, true) != crUnknownCommand) // We use HandleCommand as opposed to ExecuteCommand to accomodate the need to the WasCommandForbidden bool
+ switch (HandleCommand(a_Player, a_Message, true))
{
- return true; // Chat message was handled as command
+ case crExecuted: return true;
+ case crError: a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str())); return true;
+ case crBlocked: return true; // The plugin that blocked the command probably wants to send a message to the player.
+ case crNoPermission: a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str())); return true;
+ case crUnknownCommand: break;
}
// Check if it was a standard command (starts with a slash)
@@ -1343,7 +1347,6 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
!a_Player->HasPermission(cmd->second.m_Permission)
)
{
- a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", Split[0].c_str()));
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str());
return crNoPermission;
}
@@ -1352,7 +1355,6 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
{
- a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", Split[0].c_str()));
return crError;
}
--
cgit v1.2.3
From 546aab7b4a3e1fd28e912a9cb6507f04dbf7bd17 Mon Sep 17 00:00:00 2001
From: STRWarrior
Date: Fri, 4 Jul 2014 15:36:29 +0200
Subject: Removed useless sentence in cPluginManager:ExecuteCommand
description.
---
MCServer/Plugins/APIDump/APIDesc.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 412fcc405..271340090 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -1872,7 +1872,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
CallPlugin = { Params = "PluginName, FunctionName, [FunctionArgs...]", Return = "[FunctionRets]", Notes = "(STATIC) Calls the specified function in the specified plugin, passing all the given arguments to it. If it succeeds, it returns all the values returned by that function. If it fails, returns no value at all. Note that only strings, numbers, bools, nils and classes can be used for parameters and return values; tables and functions cannot be copied across plugins." },
DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." },
- ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns a {{cPluginManager#CommandResult|CommandResult}} value." },
+ ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Executes the command as if given by the specified Player. Checks permissions." },
FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" },
ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "{{cPluginManager#CommandResult|CommandResult}}", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature: function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
--
cgit v1.2.3
From c7a5347cd63f9e39e9732ee4720423824fb41175 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 4 Jul 2014 15:54:39 +0200
Subject: cPluginManager: Reformatted the switch statement.
---
src/Bindings/PluginManager.cpp | 41 ++++++++++++++++++++++++++++++++++-------
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 45bcc61cd..7e6502515 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -257,17 +257,44 @@ bool cPluginManager::CallHookBlockToPickups(
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
+ // Check if the message contains a command, execute it:
switch (HandleCommand(a_Player, a_Message, true))
{
- case crExecuted: return true;
- case crError: a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str())); return true;
- case crBlocked: return true; // The plugin that blocked the command probably wants to send a message to the player.
- case crNoPermission: a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str())); return true;
- case crUnknownCommand: break;
+ case crExecuted:
+ {
+ // The command has executed successfully
+ return true;
+ }
+
+ case crBlocked:
+ {
+ // The command was blocked by a plugin using HOOK_EXECUTE_COMMAND
+ // The plugin has most likely sent a message to the player already
+ return true;
+ }
+
+ case crError:
+ {
+ // An error in the plugin has prevented the command from executing. Report the error to the player:
+ a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
+ return true;
+ }
+
+ case crNoPermission:
+ {
+ // The player is not allowed to execute this command
+ a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str()));
+ return true;
+ }
+
+ case crUnknownCommand:
+ {
+ // This was not a known command, keep processing as a message
+ break;
+ }
}
- // Check if it was a standard command (starts with a slash)
- // If it was, we know that it was completely unrecognised
+ // Check if the message is a command (starts with a slash). If it is, we know that it wasn't recognised:
if (!a_Message.empty() && (a_Message[0] == '/'))
{
AStringVector Split(StringSplit(a_Message, " "));
--
cgit v1.2.3
From f4e3c01a710a2cc5118807a65f8d27519a19ef37 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 16:49:24 +0100
Subject: Various fixed
* Fixed potential invalid pointer dereferencing, fixes #1117
* Fixed ender pearls not being loaded properly
---
src/Entities/ProjectileEntity.cpp | 75 +++++++++++++++++++++++++++++++--
src/Entities/ProjectileEntity.h | 34 +++++++++++++--
src/Entities/ThrownEnderPearlEntity.cpp | 8 ++--
src/WorldStorage/NBTChunkSerializer.cpp | 11 ++---
4 files changed, 111 insertions(+), 17 deletions(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 76daca186..ddcc0f7fd 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -21,6 +21,7 @@
#include "FireChargeEntity.h"
#include "FireworkEntity.h"
#include "GhastFireballEntity.h"
+#include "Player.h"
@@ -215,7 +216,7 @@ protected:
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) :
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
- m_Creator(a_Creator),
+ m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""),
m_IsInGround(false)
{
}
@@ -227,7 +228,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) :
super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
- m_Creator(a_Creator),
+ m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""),
m_IsInGround(false)
{
SetSpeed(a_Speed);
@@ -295,6 +296,74 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
+cEntity * cProjectileEntity::GetCreator()
+{
+ if (m_CreatorData.m_Name.empty())
+ {
+ class cProjectileCreatorCallback : public cEntityCallback
+ {
+ public:
+ cProjectileCreatorCallback(void) :
+ m_Entity(NULL)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ m_Entity = a_Entity;
+ return true;
+ }
+
+ cEntity * GetEntity(void)
+ {
+ return m_Entity;
+ }
+
+ private:
+
+ cEntity * m_Entity;
+ };
+
+ cProjectileCreatorCallback PCC;
+ GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC);
+ return PCC.GetEntity();
+ }
+ else
+ {
+ class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback
+ {
+ public:
+ cProjectileCreatorCallbackForPlayers(void) :
+ m_Entity(NULL)
+ {
+ }
+
+ virtual bool Item(cPlayer * a_Entity) override
+ {
+ m_Entity = a_Entity;
+ return true;
+ }
+
+ cPlayer * GetEntity(void)
+ {
+ return m_Entity;
+ }
+
+ private:
+
+ cPlayer * m_Entity;
+ };
+
+ cProjectileCreatorCallbackForPlayers PCCFP;
+ GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP);
+ return PCCFP.GetEntity();
+ }
+}
+
+
+
+
+
AString cProjectileEntity::GetMCAClassName(void) const
{
switch (m_ProjectileKind)
@@ -304,7 +373,7 @@ AString cProjectileEntity::GetMCAClassName(void) const
case pkEgg: return "Egg";
case pkGhastFireball: return "Fireball";
case pkFireCharge: return "SmallFireball";
- case pkEnderPearl: return "ThrownEnderPearl";
+ case pkEnderPearl: return "ThrownEnderpearl";
case pkExpBottle: return "ThrownExpBottle";
case pkSplashPotion: return "ThrownPotion";
case pkWitherSkull: return "WitherSkull";
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index ae06b072f..e2ebe9f27 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -66,8 +66,15 @@ public:
/// Returns the kind of the projectile (fast class identification)
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
- /// Returns the entity who created this projectile; may be NULL
- cEntity * GetCreator(void) { return m_Creator; }
+ /** Returns the entity who created this projectile through running its Unique ID through cWorld::DoWithEntityByID()
+ May return NULL; do not store the returned pointer outside the scope of the tick thread!
+ */
+ cEntity * GetCreator(void);
+
+ /** Returns the name of the player that created the projectile
+ Will be empty for non-player creators
+ */
+ AString GetCreatorName(void) const { return m_CreatorData.m_Name; }
/// Returns the string that is used as the entity type (class name) in MCA files
AString GetMCAClassName(void) const;
@@ -81,10 +88,29 @@ public:
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
protected:
+
+ /** A structure that stores the Entity ID and Playername of the projectile's creator
+ Used to migitate invalid pointers caused by the creator being destroyed
+ */
+ struct CreatorData
+ {
+ CreatorData(int a_UniqueID, AString & a_Name) :
+ m_UniqueID(a_UniqueID),
+ m_Name(a_Name)
+ {
+ }
+
+ const int m_UniqueID;
+ AString m_Name;
+ };
+
+ /** The type of projectile I am */
eKind m_ProjectileKind;
- /// The entity who has created this projectile; may be NULL (e. g. for dispensers)
- cEntity * m_Creator;
+ /** The structure for containing the entity ID and name who has created this projectile
+ The ID and/or name may be NULL (e.g. for dispensers/mobs)
+ */
+ CreatorData m_CreatorData;
/// True if the projectile has hit the ground and is stuck there
bool m_IsInGround;
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index a3ee23389..96dd41ee6 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -46,10 +46,12 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{
+ cEntity * Creator = GetCreator();
+
// Teleport the creator here, make them take 5 damage:
- if (m_Creator != NULL)
+ if (Creator != NULL)
{
- m_Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z);
- m_Creator->TakeDamage(dtEnderPearl, this, 5, 0);
+ Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z);
+ Creator->TakeDamage(dtEnderPearl, this, 5, 0);
}
}
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index e49042ff7..2dcae51ce 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -619,14 +619,11 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
{
ASSERT(!"Unsaved projectile entity!");
}
- } // switch (ProjectileKind)
- cEntity * Creator = a_Projectile->GetCreator();
- if (Creator != NULL)
+ } // switch (ProjectileKind)
+
+ if (!a_Projectile->GetCreatorName().empty())
{
- if (Creator->GetEntityType() == cEntity::etPlayer)
- {
- m_Writer.AddString("ownerName", ((cPlayer *)Creator)->GetName());
- }
+ m_Writer.AddString("ownerName", a_Projectile->GetCreatorName());
}
m_Writer.EndCompound();
}
--
cgit v1.2.3
From 2ead2538b108c8bf6b6c43648310ad7cf7073adc Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 16:52:52 +0100
Subject: MCS WebAdmin sockets rebinds instantly
* Fixes #272
* Fixes #1150
---
src/HTTPServer/HTTPServer.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index d288c83c9..036b2e042 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -179,6 +179,8 @@ bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_Port
// Open up requested ports:
bool HasAnyPort;
+ m_ListenThreadIPv4.SetReuseAddr(true);
+ m_ListenThreadIPv6.SetReuseAddr(true);
HasAnyPort = m_ListenThreadIPv4.Initialize(a_PortsIPv4);
HasAnyPort = m_ListenThreadIPv6.Initialize(a_PortsIPv6) || HasAnyPort;
if (!HasAnyPort)
--
cgit v1.2.3
From 79e558be349c40ed40b5eefefd29f563a570e404 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 17:42:40 +0100
Subject: Suggestions
---
src/Entities/ThrownEggEntity.cpp | 2 +-
src/Entities/ThrownEggEntity.h | 5 ++++-
src/Entities/ThrownEnderPearlEntity.cpp | 2 +-
src/Entities/ThrownEnderPearlEntity.h | 5 ++++-
src/Entities/ThrownSnowballEntity.cpp | 2 +-
src/Entities/ThrownSnowballEntity.h | 5 ++++-
src/Vector3.h | 10 +++++-----
7 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index d7eed41e3..456083108 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -22,7 +22,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
{
TrySpawnChicken(a_HitPos);
- m_DestroyTimer = 5;
+ m_DestroyTimer = 2;
}
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index 894665428..dc72c279f 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -41,7 +41,10 @@ protected:
return;
}
}
- else { super::Tick(a_Dt, a_Chunk); }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
}
// Randomly decides whether to spawn a chicken where the egg lands.
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index 96dd41ee6..aeb727205 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -22,7 +22,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF
// TODO: Tweak a_HitPos based on block face.
TeleportCreator(a_HitPos);
- m_DestroyTimer = 5;
+ m_DestroyTimer = 2;
}
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index bfd9bd70d..1cea5f7d9 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -41,7 +41,10 @@ protected:
return;
}
}
- else { super::Tick(a_Dt, a_Chunk); }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
}
/** Teleports the creator where the ender pearl lands */
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index b82cd56db..d94e75898 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -20,7 +20,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do
void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- m_DestroyTimer = 5;
+ m_DestroyTimer = 2;
}
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index e30971f0a..9a8770379 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -41,7 +41,10 @@ protected:
return;
}
}
- else { super::Tick(a_Dt, a_Chunk); }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
}
private:
diff --git a/src/Vector3.h b/src/Vector3.h
index faf7fe43c..f350ede2a 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -135,12 +135,12 @@ public:
}
/** Runs each value of the vector through std::floor() */
- inline Vector3 Floor(void) const
+ inline Vector3 Floor(void) const
{
- return Vector3(
- (T)floor(x),
- (T)floor(y),
- (T)floor(z)
+ return Vector3i(
+ (int)floor(x),
+ (int)floor(y),
+ (int)floor(z)
);
}
--
cgit v1.2.3
From 25e986220662247cfeefe4a496da959f409859e9 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 17:49:44 +0100
Subject: Compile fix
---
src/Vector3.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Vector3.h b/src/Vector3.h
index f350ede2a..9e855b8af 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -137,7 +137,7 @@ public:
/** Runs each value of the vector through std::floor() */
inline Vector3 Floor(void) const
{
- return Vector3i(
+ return Vector3(
(int)floor(x),
(int)floor(y),
(int)floor(z)
--
cgit v1.2.3
From f4e11d194e9e4a2e85a9f9688312ad08ade45b83 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 4 Jul 2014 22:07:26 +0100
Subject: Crash and compile fix
---
src/Entities/ProjectileEntity.cpp | 11 ++++++++---
src/Entities/ProjectileEntity.h | 2 +-
src/Protocol/Protocol17x.cpp | 2 +-
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index ddcc0f7fd..50f62b018 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -216,7 +216,10 @@ protected:
cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) :
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
- m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : ""),
+ m_CreatorData(
+ ((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
+ ((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : "")
+ ),
m_IsInGround(false)
{
}
@@ -298,7 +301,7 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
cEntity * cProjectileEntity::GetCreator()
{
- if (m_CreatorData.m_Name.empty())
+ if (m_CreatorData.m_Name.empty() && (m_CreatorData.m_UniqueID >= 1))
{
class cProjectileCreatorCallback : public cEntityCallback
{
@@ -328,7 +331,7 @@ cEntity * cProjectileEntity::GetCreator()
GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC);
return PCC.GetEntity();
}
- else
+ else if (!m_CreatorData.m_Name.empty())
{
class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback
{
@@ -358,6 +361,8 @@ cEntity * cProjectileEntity::GetCreator()
GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP);
return PCCFP.GetEntity();
}
+
+ return NULL;
}
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index e2ebe9f27..84eefb9ee 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -94,7 +94,7 @@ protected:
*/
struct CreatorData
{
- CreatorData(int a_UniqueID, AString & a_Name) :
+ CreatorData(int a_UniqueID, const AString & a_Name) :
m_UniqueID(a_UniqueID),
m_Name(a_Name)
{
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 02c577dc8..109e5a67b 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -2334,7 +2334,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings
{
- AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a newline, used internally by MCS to display a new line in the client; don't forget to c_str ;)
+ AppendPrintf(Lore, "%s`", NBT.GetString(loretag).c_str()); // Append the lore with a grave accent/backtick, used internally by MCS to display a new line in the client; don't forget to c_str ;)
}
a_Item.m_Lore = Lore;
--
cgit v1.2.3
From 7a78f23b4a03d36dc6db56a7e269f5c181c2a6fb Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sat, 5 Jul 2014 14:00:04 +0200
Subject: Add middle click.
---
src/UI/SlotArea.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++----------
src/UI/SlotArea.h | 7 ++--
2 files changed, 88 insertions(+), 21 deletions(-)
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 48ebf489b..3e171a444 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -15,6 +15,7 @@
#include "../Root.h"
#include "../FastRandom.h"
#include "../BlockArea.h"
+#include "polarssl/camellia.h"
@@ -60,12 +61,16 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
return;
}
-
case caDblClick:
{
DblClicked(a_Player, a_SlotNum);
return;
}
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
default:
{
break;
@@ -226,6 +231,24 @@ void cSlotArea::DblClicked(cPlayer & a_Player, int a_SlotNum)
+void cSlotArea::MiddleClicked(cPlayer & a_Player, int a_SlotNum)
+{
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+
+ if (!a_Player.IsGameModeCreative() || Slot.IsEmpty() || !DraggingItem.IsEmpty())
+ {
+ return;
+ }
+
+ DraggingItem = Slot;
+ DraggingItem.m_ItemCount = DraggingItem.GetMaxStackSize();
+}
+
+
+
+
+
void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
{
UNUSED(a_Player);
@@ -410,6 +433,12 @@ cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) :
void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
+ if (a_ClickAction == caMiddleClick)
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+
// Override for craft result slot
if (a_SlotNum == 0)
{
@@ -423,6 +452,7 @@ void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction
}
return;
}
+
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
UpdateRecipe(a_Player);
}
@@ -651,15 +681,27 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
return;
}
- if (a_ClickAction == caDblClick)
- {
- return;
- }
-
- if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ switch (a_ClickAction)
{
- ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
- return;
+ case caDblClick:
+ {
+ return;
+ }
+ case caShiftLeftClick:
+ case caShiftRightClick:
+ {
+ ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ return;
+ }
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ default:
+ {
+ break;
+ }
}
cItem Slot(*GetSlot(a_SlotNum, a_Player));
@@ -1057,12 +1099,16 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
return;
}
-
case caDblClick:
{
DblClicked(a_Player, a_SlotNum);
return;
}
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
default:
{
break;
@@ -1414,6 +1460,12 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
return;
}
+ if (a_ClickAction == caMiddleClick)
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+
cItem & DraggingItem = a_Player.GetDraggingItem();
if (!DraggingItem.IsEmpty())
{
@@ -1676,16 +1728,28 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
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)
+ switch (a_ClickAction)
{
- return;
+ case caDblClick:
+ {
+ // Armors haven't a dbl click
+ return;
+ }
+ case caShiftLeftClick:
+ case caShiftRightClick:
+ {
+ ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ return;
+ }
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ default:
+ {
+ break;
+ }
}
cItem Slot(*GetSlot(a_SlotNum, a_Player));
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index b4b693cf6..b72450a58 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -46,10 +46,13 @@ public:
/// Called from Clicked when the action is a shiftclick (left or right)
virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem);
-
+
/// Called from Clicked when the action is a caDblClick
virtual void DblClicked(cPlayer & a_Player, int a_SlotNum);
-
+
+ /** Called from Clicked when the action is a middleclick */
+ virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum);
+
/// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
virtual void OnPlayerAdded(cPlayer & a_Player);
--
cgit v1.2.3
From 460d6bd0cbb799a6e68f1bc264f55c3d89eb8206 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 5 Jul 2014 22:59:22 +0100
Subject: Changed everything to callbacks
---
src/Entities/ProjectileEntity.cpp | 72 +--------------------------------
src/Entities/ProjectileEntity.h | 6 +--
src/Entities/ThrownEnderPearlEntity.cpp | 35 +++++++++++++---
src/Mobs/Creeper.cpp | 22 +++++++++-
4 files changed, 53 insertions(+), 82 deletions(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 50f62b018..334973833 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -142,7 +142,7 @@ public:
{
if (
(a_Entity == m_Projectile) || // Do not check collisions with self
- (a_Entity == m_Projectile->GetCreator()) // Do not check whoever shot the projectile
+ (a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile
)
{
// TODO: Don't check creator only for the first 5 ticks
@@ -299,76 +299,6 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
-cEntity * cProjectileEntity::GetCreator()
-{
- if (m_CreatorData.m_Name.empty() && (m_CreatorData.m_UniqueID >= 1))
- {
- class cProjectileCreatorCallback : public cEntityCallback
- {
- public:
- cProjectileCreatorCallback(void) :
- m_Entity(NULL)
- {
- }
-
- virtual bool Item(cEntity * a_Entity) override
- {
- m_Entity = a_Entity;
- return true;
- }
-
- cEntity * GetEntity(void)
- {
- return m_Entity;
- }
-
- private:
-
- cEntity * m_Entity;
- };
-
- cProjectileCreatorCallback PCC;
- GetWorld()->DoWithEntityByID(m_CreatorData.m_UniqueID, PCC);
- return PCC.GetEntity();
- }
- else if (!m_CreatorData.m_Name.empty())
- {
- class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback
- {
- public:
- cProjectileCreatorCallbackForPlayers(void) :
- m_Entity(NULL)
- {
- }
-
- virtual bool Item(cPlayer * a_Entity) override
- {
- m_Entity = a_Entity;
- return true;
- }
-
- cPlayer * GetEntity(void)
- {
- return m_Entity;
- }
-
- private:
-
- cPlayer * m_Entity;
- };
-
- cProjectileCreatorCallbackForPlayers PCCFP;
- GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP);
- return PCCFP.GetEntity();
- }
-
- return NULL;
-}
-
-
-
-
-
AString cProjectileEntity::GetMCAClassName(void) const
{
switch (m_ProjectileKind)
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 84eefb9ee..7b38169e2 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -66,10 +66,10 @@ public:
/// Returns the kind of the projectile (fast class identification)
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
- /** Returns the entity who created this projectile through running its Unique ID through cWorld::DoWithEntityByID()
- May return NULL; do not store the returned pointer outside the scope of the tick thread!
+ /** Returns the unique ID of the entity who created this projectile
+ May return an ID <0
*/
- cEntity * GetCreator(void);
+ int GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; }
/** Returns the name of the player that created the projectile
Will be empty for non-player creators
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index aeb727205..c7407e6ae 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -1,6 +1,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "ThrownEnderPearlEntity.h"
+#include "Player.h"
@@ -46,12 +47,34 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{
- cEntity * Creator = GetCreator();
-
- // Teleport the creator here, make them take 5 damage:
- if (Creator != NULL)
+ if (m_CreatorData.m_Name.empty())
{
- Creator->TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z);
- Creator->TakeDamage(dtEnderPearl, this, 5, 0);
+ return;
}
+
+ class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback
+ {
+ public:
+ cProjectileCreatorCallbackForPlayers(cEntity * a_Attacker, Vector3i a_HitPos) :
+ m_Attacker(a_Attacker),
+ m_HitPos(a_HitPos)
+ {
+ }
+
+ virtual bool Item(cPlayer * a_Entity) override
+ {
+ // Teleport the creator here, make them take 5 damage:
+ a_Entity->TeleportToCoords(m_HitPos.x, m_HitPos.y + 0.2, m_HitPos.z);
+ a_Entity->TakeDamage(dtEnderPearl, m_Attacker, 5, 0);
+ return true;
+ }
+
+ private:
+
+ cEntity * m_Attacker;
+ Vector3i m_HitPos;
+ };
+
+ cProjectileCreatorCallbackForPlayers PCCFP(this, a_HitPos);
+ GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP);
}
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index a7b97f604..b9041bd5a 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -67,9 +67,27 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
- if ((a_Killer != NULL) && (a_Killer->IsProjectile()))
+ if ((a_Killer != NULL) && a_Killer->IsProjectile() && (((cProjectileEntity *)a_Killer)->GetCreatorUniqueID() >= 0))
{
- if (((cMonster *)((cProjectileEntity *)a_Killer)->GetCreator())->GetMobType() == mtSkeleton)
+ class cProjectileCreatorCallback : public cEntityCallback
+ {
+ public:
+ cProjectileCreatorCallback(void)
+ {
+ }
+
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if (a_Entity->IsMob() && ((cMonster *)a_Entity)->GetMobType() == mtSkeleton)
+ {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ cProjectileCreatorCallback PCC;
+ if (GetWorld()->DoWithEntityByID(((cProjectileEntity *)a_Killer)->GetCreatorUniqueID(), PCC))
{
// 12 music discs. TickRand starts from 0 to 11. Disk IDs start at 2256, so add that. There.
AddRandomDropItem(a_Drops, 1, 1, (short)m_World->GetTickRandomNumber(11) + 2256);
--
cgit v1.2.3
From 9d7a59012c428e0207583f35c79938bcdab625b5 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 6 Jul 2014 00:40:59 +0200
Subject: Added drop window action.
---
src/UI/SlotArea.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++++-----
src/UI/SlotArea.h | 6 +++
src/UI/Window.cpp | 22 ++++-------
3 files changed, 113 insertions(+), 25 deletions(-)
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 3e171a444..68ec78930 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -71,6 +71,12 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
MiddleClicked(a_Player, a_SlotNum);
return;
}
+ case caDropKey:
+ case caCtrlDropKey:
+ {
+ DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
+ return;
+ }
default:
{
break;
@@ -249,6 +255,34 @@ void cSlotArea::MiddleClicked(cPlayer & a_Player, int a_SlotNum)
+void cSlotArea::DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack)
+{
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ if (Slot.IsEmpty())
+ {
+ return;
+ }
+
+ cItem ItemToDrop = Slot.CopyOne();
+ if (a_DropStack)
+ {
+ ItemToDrop.m_ItemCount = Slot.m_ItemCount;
+ }
+
+ Slot.m_ItemCount -= ItemToDrop.m_ItemCount;
+ if (Slot.m_ItemCount <= 0)
+ {
+ Slot.Empty();
+ }
+ SetSlot(a_SlotNum, a_Player, Slot);
+
+ a_Player.TossPickup(ItemToDrop);
+}
+
+
+
+
+
void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
{
UNUSED(a_Player);
@@ -446,6 +480,10 @@ void cSlotAreaCrafting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction
{
ShiftClickedResult(a_Player);
}
+ else if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey))
+ {
+ DropClickedResult(a_Player);
+ }
else
{
ClickedResult(a_Player);
@@ -594,6 +632,27 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
+void cSlotAreaCrafting::DropClickedResult(cPlayer & a_Player)
+{
+ // Get the current recipe:
+ cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
+ const cItem & Result = Recipe.GetResult();
+
+ cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
+ cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
+
+ a_Player.TossPickup(Result);
+ Recipe.ConsumeIngredients(Grid);
+ Grid.CopyToItems(PlayerSlots);
+
+ HandleCraftItem(Result, a_Player);
+ UpdateRecipe(a_Player);
+}
+
+
+
+
+
void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
{
cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
@@ -698,6 +757,16 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
MiddleClicked(a_Player, a_SlotNum);
return;
}
+ case caDropKey:
+ case caCtrlDropKey:
+ {
+ if (CanTakeResultItem(a_Player))
+ {
+ DropClicked(a_Player, a_SlotNum, true);
+ OnTakeResult(a_Player);
+ }
+ return;
+ }
default:
{
break;
@@ -1453,17 +1522,32 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
bAsync = true;
}
- if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ switch (a_ClickAction)
{
- HandleSmeltItem(Slot, a_Player);
- ShiftClicked(a_Player, a_SlotNum, Slot);
- return;
- }
-
- if (a_ClickAction == caMiddleClick)
- {
- MiddleClicked(a_Player, a_SlotNum);
- return;
+ case caShiftLeftClick:
+ case caShiftRightClick:
+ {
+ HandleSmeltItem(Slot, a_Player);
+ ShiftClicked(a_Player, a_SlotNum, Slot);
+ return;
+ }
+ case caMiddleClick:
+ {
+ MiddleClicked(a_Player, a_SlotNum);
+ return;
+ }
+ case caDropKey:
+ case caCtrlDropKey:
+ {
+ DropClicked(a_Player, a_SlotNum, (a_SlotNum == caCtrlDropKey));
+ Slot.m_ItemCount = Slot.m_ItemCount - GetSlot(a_SlotNum, a_Player)->m_ItemCount;
+ HandleSmeltItem(Slot, a_Player);
+ return;
+ }
+ default:
+ {
+ break;
+ }
}
cItem & DraggingItem = a_Player.GetDraggingItem();
@@ -1641,6 +1725,12 @@ void cSlotAreaInventoryBase::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAc
{
if (a_Player.IsGameModeCreative() && (m_ParentWindow.GetWindowType() == cWindow::wtInventory))
{
+ if ((a_ClickAction == caDropKey) || (a_ClickAction == caCtrlDropKey))
+ {
+ DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
+ return;
+ }
+
// Creative inventory must treat a_ClickedItem as a DraggedItem instead, replacing the inventory slot with it
SetSlot(a_SlotNum, a_Player, a_ClickedItem);
return;
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index b72450a58..03f538956 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -53,6 +53,9 @@ public:
/** Called from Clicked when the action is a middleclick */
virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum);
+ /** Called from Clicked when the action is a drop click. */
+ virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack);
+
/// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
virtual void OnPlayerAdded(cPlayer & a_Player);
@@ -251,6 +254,9 @@ protected:
/// Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result.
void ShiftClickedResult(cPlayer & a_Player);
+
+ /** Handles a drop-click in the result slot. */
+ void DropClickedResult(cPlayer & a_Player);
/// Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player
void UpdateRecipe(cPlayer & a_Player);
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 381c6e121..ebdc1aea8 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -178,6 +178,7 @@ void cWindow::Clicked(
switch (a_ClickAction)
{
+ case caLeftClickOutside:
case caRightClickOutside:
{
if (PlgMgr->CallHookPlayerTossingItem(a_Player))
@@ -190,25 +191,16 @@ void cWindow::Clicked(
a_Player.TossPickup(a_ClickedItem);
}
- // Toss one of the dragged items:
- a_Player.TossHeldItem();
- return;
- }
- case caLeftClickOutside:
- {
- if (PlgMgr->CallHookPlayerTossingItem(a_Player))
+ if (a_ClickAction == caLeftClickOutside)
{
- // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
- return;
+ // Toss all dragged items:
+ a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
}
-
- if (a_Player.IsGameModeCreative())
+ else
{
- a_Player.TossPickup(a_ClickedItem);
+ // Toss one of the dragged items:
+ a_Player.TossHeldItem();
}
-
- // Toss all dragged items:
- a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
return;
}
case caLeftClickOutsideHoldNothing:
--
cgit v1.2.3
From 66fa0155345f33a3be5661495af2f20d964b62b6 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 5 Jul 2014 13:36:56 +0200
Subject: Fixed slime handling in cMonster::StringToMobType().
---
src/Mobs/Monster.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 5843ca5a6..aaef7580d 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -46,8 +46,8 @@ static const struct
{cMonster::mtSheep, "sheep"},
{cMonster::mtSilverfish, "silverfish"},
{cMonster::mtSkeleton, "skeleton"},
- {cMonster::mtSnowGolem, "snowgolem"},
{cMonster::mtSlime, "slime"},
+ {cMonster::mtSnowGolem, "snowgolem"},
{cMonster::mtSpider, "spider"},
{cMonster::mtSquid, "squid"},
{cMonster::mtVillager, "villager"},
--
cgit v1.2.3
From 562d14e8ecd058b029a248ab42ff60e36f7e2e62 Mon Sep 17 00:00:00 2001
From: Mattes D
Date: Sun, 6 Jul 2014 14:42:28 +0200
Subject: Fixed crafting grid updating.
Fixes #1152.
---
src/UI/SlotArea.cpp | 22 ++++++++++++++++++++--
src/UI/SlotArea.h | 1 +
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 48ebf489b..4df04c9e2 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -468,6 +468,20 @@ void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
+void cSlotAreaCrafting::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ // Update the recipe after setting the slot, if the slot is not the result slot:
+ super::SetSlot(a_SlotNum, a_Player, a_Item);
+ if (a_SlotNum != 0)
+ {
+ UpdateRecipe(a_Player);
+ }
+}
+
+
+
+
+
void cSlotAreaCrafting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
{
UNUSED(a_ItemStack);
@@ -545,16 +559,20 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
// Distribute the result, this time for real:
ResultCopy = Result;
m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, true);
-
+
// Remove the ingredients from the crafting grid and update the recipe:
cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
Recipe.ConsumeIngredients(Grid);
Grid.CopyToItems(PlayerSlots);
UpdateRecipe(a_Player);
+
+ // Broadcast the window, we sometimes move items to different locations than Vanilla, causing needless desyncs:
+ m_ParentWindow.BroadcastWholeWindow();
+
+ // If the recipe has changed, bail out:
if (!Recipe.GetResult().IsEqual(Result))
{
- // The recipe has changed, bail out
return;
}
}
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index b4b693cf6..e271ea454 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -232,6 +232,7 @@ public:
virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
virtual void DblClicked (cPlayer & a_Player, int a_SlotNum);
virtual void OnPlayerRemoved(cPlayer & a_Player) override;
+ virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
// Distributing items into this area is completely disabled
virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
--
cgit v1.2.3
From c3bd588826cd6de53f98cf96f2d275fc15df6f4f Mon Sep 17 00:00:00 2001
From: tycho
Date: Sun, 6 Jul 2014 16:27:50 +0100
Subject: Fixed OpenSSL programs and tests being generated when testing
disabled.
---
lib/polarssl.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/polarssl.cmake b/lib/polarssl.cmake
index 91f0fa145..ced70b94e 100644
--- a/lib/polarssl.cmake
+++ b/lib/polarssl.cmake
@@ -1,9 +1,9 @@
if(NOT TARGET polarssl)
message("including polarssl")
+ set(ENABLE_TESTING OFF CACHE BOOL "Disable tests")
+ set(ENABLE_PROGRAMS OFF CACHE BOOL "Disable programs")
if (SELF_TEST)
- set(ENABLE_TESTING OFF CACHE BOOL "Disable tests")
- set(ENABLE_PROGRAMS OFF CACHE BOOL "Disable programs")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl EXCLUDE_FROM_ALL)
--
cgit v1.2.3
From 9e44b0aae164f2456a452714f869cc9670732d8e Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 6 Jul 2014 23:50:22 +0100
Subject: Implemented trapped chests & others
+ Added trapped chests
* Fixed a bunch of bugs in the redstone simulator concerning wires and
repeaters
* Other potential bugfixes
---
src/BlockEntities/BlockEntity.cpp | 3 +-
src/BlockEntities/ChestEntity.cpp | 7 +-
src/BlockEntities/ChestEntity.h | 13 +-
src/BlockEntities/HopperEntity.cpp | 26 +++-
src/BlockInfo.cpp | 3 +
src/Blocks/BlockChest.h | 44 +++---
src/Blocks/BlockHandler.cpp | 1 +
src/Blocks/BlockPiston.cpp | 2 +-
src/Blocks/BlockPiston.h | 18 +--
src/Chunk.cpp | 8 +-
src/ChunkMap.cpp | 21 ++-
src/ChunkMap.h | 3 +-
src/Entities/ExpOrb.h | 2 +-
src/Map.cpp | 4 +-
src/Protocol/Authenticator.cpp | 4 +-
src/Simulator/IncrementalRedstoneSimulator.cpp | 205 +++++++++++++++----------
src/Simulator/IncrementalRedstoneSimulator.h | 28 +++-
src/UI/Window.cpp | 65 +++++++-
src/UI/Window.h | 7 +-
src/World.cpp | 17 +-
src/World.h | 15 +-
src/WorldStorage/NBTChunkSerializer.cpp | 7 +-
src/WorldStorage/NBTChunkSerializer.h | 2 +-
src/WorldStorage/WSSAnvil.cpp | 10 +-
src/WorldStorage/WSSAnvil.h | 2 +-
src/WorldStorage/WSSCompact.cpp | 2 +-
26 files changed, 340 insertions(+), 179 deletions(-)
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index 430f04551..1e2a176ef 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -28,7 +28,8 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
switch (a_BlockType)
{
case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_TRAPPED_CHEST:
+ case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index cb9cc89bf..8626f3cad 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -11,8 +11,9 @@
-cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
- super(E_BLOCK_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
+cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type) :
+ super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+ m_ActivePlayers(0)
{
cBlockEntityWindowOwner::SetBlockEntity(this);
}
@@ -113,7 +114,7 @@ void cChestEntity::UsedBy(cPlayer * a_Player)
// The few false positives aren't much to worry about
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(m_PosX, m_PosZ, ChunkX, ChunkZ);
- m_World->MarkChunkDirty(ChunkX, ChunkZ);
+ m_World->MarkChunkDirty(ChunkX, ChunkZ, true);
}
diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h
index ce16f84d7..42cf7657c 100644
--- a/src/BlockEntities/ChestEntity.h
+++ b/src/BlockEntities/ChestEntity.h
@@ -35,7 +35,7 @@ public:
// tolua_end
/// Constructor used for normal operation
- cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+ cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
virtual ~cChestEntity();
@@ -50,6 +50,17 @@ public:
/// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
void OpenNewWindow(void);
+
+ /** Gets the number of players who currently have this chest open */
+ int GetNumberOfPlayers(void) const { return m_ActivePlayers; }
+
+ /** Gets the number of players who currently have this chest open */
+ void SetNumberOfPlayers(int a_Amount) { m_ActivePlayers = a_Amount; }
+
+private:
+
+ /** Holds the number of players who currently have this chest open */
+ int m_ActivePlayers;
} ; // tolua_export
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 5856f20d1..bcaf26701 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -157,6 +157,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
bool res = false;
switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
{
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
{
// Chests have special handling because of double-chests
@@ -322,6 +323,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
bool res = false;
switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ))
{
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
{
// Chests have special handling because of double-chests
@@ -395,13 +397,17 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
int x = m_RelX + Coords[i].x;
int z = m_RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
- if (
- (Neighbor == NULL) ||
- (Neighbor->GetBlock(x, m_PosY + 1, z) != E_BLOCK_CHEST)
- )
+ if (Neighbor == NULL)
{
continue;
}
+
+ BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z);
+ if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST))
+ {
+ continue;
+ }
+
Chest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
if (Chest == NULL)
{
@@ -572,13 +578,17 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
int x = RelX + Coords[i].x;
int z = RelZ + Coords[i].z;
cChunk * Neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(x, z);
- if (
- (Neighbor == NULL) ||
- (Neighbor->GetBlock(x, a_BlockY, z) != E_BLOCK_CHEST)
- )
+ if (Neighbor == NULL)
{
continue;
}
+
+ BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z);
+ if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST))
+ {
+ continue;
+ }
+
Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z);
if (Chest == NULL)
{
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 16314290a..6ceb2c697 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -101,6 +101,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRAPPED_CHEST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
@@ -162,6 +163,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_TRAPPED_CHEST ].m_Transparent = true;
a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true;
a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
@@ -287,6 +289,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
a_Info[E_BLOCK_TNT ].m_IsSnowable = false;
a_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
+ a_Info[E_BLOCK_TRAPPED_CHEST ].m_IsSnowable = false;
a_Info[E_BLOCK_TRIPWIRE ].m_IsSnowable = false;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_IsSnowable = false;
a_Info[E_BLOCK_VINES ].m_IsSnowable = false;
diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h
index c9a769c75..f899f4bcb 100644
--- a/src/Blocks/BlockChest.h
+++ b/src/Blocks/BlockChest.h
@@ -44,16 +44,16 @@ public:
}
double yaw = a_Player->GetYaw();
if (
- (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(0, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
)
{
a_BlockMeta = ((yaw >= -90) && (yaw < 90)) ? 2 : 3;
return true;
}
if (
- (Area.GetRelBlockType(0, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(0, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
)
{
// FIXME: This is unreachable, as the condition is the same as the above one
@@ -130,12 +130,12 @@ public:
}
int NumChestNeighbors = 0;
- if (Area.GetRelBlockType(1, 0, 2) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(1, 0, 2) == m_BlockType)
{
if (
- (Area.GetRelBlockType(0, 0, 2) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(0, 0, 2) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -143,12 +143,12 @@ public:
}
NumChestNeighbors += 1;
}
- if (Area.GetRelBlockType(3, 0, 2) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(3, 0, 2) == m_BlockType)
{
if (
- (Area.GetRelBlockType(4, 0, 2) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(4, 0, 2) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -156,12 +156,12 @@ public:
}
NumChestNeighbors += 1;
}
- if (Area.GetRelBlockType(2, 0, 1) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(2, 0, 1) == m_BlockType)
{
if (
- (Area.GetRelBlockType(2, 0, 0) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 1) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 1) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(2, 0, 0) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 1) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 1) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -169,12 +169,12 @@ public:
}
NumChestNeighbors += 1;
}
- if (Area.GetRelBlockType(2, 0, 3) == E_BLOCK_CHEST)
+ if (Area.GetRelBlockType(2, 0, 3) == m_BlockType)
{
if (
- (Area.GetRelBlockType(2, 0, 4) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(1, 0, 3) == E_BLOCK_CHEST) ||
- (Area.GetRelBlockType(3, 0, 3) == E_BLOCK_CHEST)
+ (Area.GetRelBlockType(2, 0, 4) == m_BlockType) ||
+ (Area.GetRelBlockType(1, 0, 3) == m_BlockType) ||
+ (Area.GetRelBlockType(3, 0, 3) == m_BlockType)
)
{
// Already a doublechest neighbor, disallow:
@@ -217,7 +217,7 @@ public:
/// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true.
bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
{
- if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != E_BLOCK_CHEST)
+ if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != m_BlockType)
{
return false;
}
@@ -228,7 +228,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(E_BLOCK_CHEST, 1, 0));
+ a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
} ;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 3ddb7531d..4ec064d2b 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -191,6 +191,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType);
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp
index faf639312..6f8d8be3e 100644
--- a/src/Blocks/BlockPiston.cpp
+++ b/src/Blocks/BlockPiston.cpp
@@ -85,7 +85,7 @@ int cBlockPistonHandler::FirstPassthroughBlock(int a_PistonX, int a_PistonY, int
NIBBLETYPE currMeta;
AddPistonDir(a_PistonX, a_PistonY, a_PistonZ, pistonmeta, 1);
a_World->GetBlockTypeMeta(a_PistonX, a_PistonY, a_PistonZ, currBlock, currMeta);
- if (CanBreakPush(currBlock))
+ if (cBlockInfo::IsPistonBreakable(currBlock))
{
// This block breaks when pushed, extend up to here
return ret;
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index e6fa48e54..3913da320 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -104,6 +104,7 @@ private:
case E_BLOCK_ENCHANTMENT_TABLE:
case E_BLOCK_END_PORTAL:
case E_BLOCK_END_PORTAL_FRAME:
+ // Ender chests can totally be pushed/pulled in MCS :)
case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_HOPPER:
@@ -113,6 +114,7 @@ private:
case E_BLOCK_NOTE_BLOCK:
case E_BLOCK_OBSIDIAN:
case E_BLOCK_PISTON_EXTENSION:
+ case E_BLOCK_TRAPPED_CHEST:
{
return false;
}
@@ -126,24 +128,10 @@ private:
return true;
}
- /// Returns true if the specified block can be pushed by a piston and broken / replaced
- static inline bool CanBreakPush(BLOCKTYPE a_BlockType) { return cBlockInfo::IsPistonBreakable(a_BlockType); }
-
/// Returns true if the specified block can be pulled by a sticky piston
static inline bool CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- switch (a_BlockType)
- {
- case E_BLOCK_LAVA:
- case E_BLOCK_STATIONARY_LAVA:
- case E_BLOCK_STATIONARY_WATER:
- case E_BLOCK_WATER:
- {
- return false;
- }
- }
-
- if (CanBreakPush(a_BlockType))
+ if (cBlockInfo::IsPistonBreakable(a_BlockType))
{
return false; // CanBreakPush returns true, but we need false to prevent pulling
}
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 0fee40cac..c1f9dbfd6 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1297,6 +1297,7 @@ void cChunk::CreateBlockEntities(void)
switch (BlockType)
{
case E_BLOCK_BEACON:
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
case E_BLOCK_COMMAND_BLOCK:
case E_BLOCK_DISPENSER:
@@ -1427,6 +1428,7 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
switch (a_BlockType)
{
case E_BLOCK_BEACON:
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST:
case E_BLOCK_COMMAND_BLOCK:
case E_BLOCK_DISPENSER:
@@ -2121,7 +2123,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
{
continue;
}
- if ((*itr)->GetBlockType() != E_BLOCK_CHEST)
+ if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST) /* Trapped chests use normal chests' handlers */)
{
// There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out
return false;
@@ -2501,8 +2503,8 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
{
int BlockX = m_PosX * cChunkDef::Width + a_RelX;
int BlockZ = m_PosZ * cChunkDef::Width + a_RelZ;
- int BlockY, ChunkX, ChunkZ;
- AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
+ int ChunkX, ChunkZ;
+ BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
return m_ChunkMap->GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index c9fb0b59e..c53211b6b 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -847,7 +847,22 @@ void cChunkMap::WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_M
-void cChunkMap::MarkChunkDirty (int a_ChunkX, int a_ChunkZ)
+void cChunkMap::MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+ if ((Chunk == NULL) || !Chunk->IsValid())
+ {
+ return;
+ }
+ Chunk->SetIsRedstoneDirty(true);
+}
+
+
+
+
+
+void cChunkMap::MarkChunkDirty(int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
@@ -856,6 +871,10 @@ void cChunkMap::MarkChunkDirty (int a_ChunkX, int a_ChunkZ)
return;
}
Chunk->MarkDirty();
+ if (a_MarkRedstoneDirty)
+ {
+ Chunk->SetIsRedstoneDirty(true);
+ }
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 433516490..9453f090f 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -106,7 +106,8 @@ public:
/** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
- void MarkChunkDirty (int a_ChunkX, int a_ChunkZ);
+ void MarkRedstoneDirty (int a_ChunkX, int a_ChunkZ);
+ void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false);
void MarkChunkSaving (int a_ChunkX, int a_ChunkZ);
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index e76274ac9..2cd4ef31f 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -11,7 +11,7 @@
class cExpOrb :
public cEntity
{
- typedef cExpOrb super;
+ typedef cEntity super;
public:
// tolua_end
diff --git a/src/Map.cpp b/src/Map.cpp
index 7721baa70..8f205a606 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -200,8 +200,8 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
int BlockX = m_CenterX + ((a_X - (m_Width / 2)) * PixelWidth);
int BlockZ = m_CenterZ + ((a_Z - (m_Height / 2)) * PixelWidth);
- int ChunkX, ChunkY, ChunkZ;
- m_World->BlockToChunk(BlockX, 0, BlockZ, ChunkX, ChunkY, ChunkZ);
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
int RelX = BlockX - (ChunkX * cChunkDef::Width);
int RelZ = BlockZ - (ChunkZ * cChunkDef::Width);
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 2050393c2..54b823e0f 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -262,7 +262,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
AString HexDump;
if (Response.compare(0, prefix.size(), prefix))
{
- LOGINFO("User \"%s\" failed to auth, bad http status line received", a_UserName.c_str());
+ LOGINFO("User %s failed to auth, bad http status line received", a_UserName.c_str());
LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return false;
}
@@ -271,7 +271,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
size_t idxHeadersEnd = Response.find("\r\n\r\n");
if (idxHeadersEnd == AString::npos)
{
- LOGINFO("User \"%s\" failed to authenticate, bad http response header received", a_UserName.c_str());
+ LOGINFO("User %s failed to authenticate, bad http response header received", a_UserName.c_str());
LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return false;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 5af9a295d..e46eb0429 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -5,6 +5,7 @@
#include "BoundingBox.h"
#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/NoteEntity.h"
+#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../Entities/TNTEntity.h"
#include "../Entities/Pickup.h"
@@ -15,8 +16,6 @@
#include "../Blocks/BlockPiston.h"
#include "../Blocks/BlockTripwireHook.h"
-#define WAKE_SIMULATOR_IF_DIRTY(a_Chunk, a_BlockX, a_BlockY, a_BlockZ) if (a_Chunk->IsRedstoneDirty()) WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
-
@@ -63,14 +62,13 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
int RelZ = 0;
BLOCKTYPE Block;
NIBBLETYPE Meta;
- cChunk * OtherChunk = a_Chunk;
if (a_OtherChunk != NULL)
{
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
- OtherChunk = a_OtherChunk;
+ a_Chunk->SetIsRedstoneDirty(true); // When the second paramter is present, it means that the first belongs to a neighbouring chunk of the coordinates - alert this chunk for changes
}
else
{
@@ -95,8 +93,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = PoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
- OtherChunk->SetIsRedstoneDirty(true);
continue;
}
else if (
@@ -112,27 +108,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = PoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
- OtherChunk->SetIsRedstoneDirty(true);
continue;
}
- else if (Block == E_BLOCK_DAYLIGHT_SENSOR)
- {
- if (!m_World.IsChunkLighted(OtherChunk->GetPosX(), OtherChunk->GetPosZ()))
- {
- m_World.QueueLightChunk(OtherChunk->GetPosX(), OtherChunk->GetPosZ());
- }
- else
- {
- if (OtherChunk->GetTimeAlteredLight(OtherChunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7)
- {
- itr = PoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
- OtherChunk->SetIsRedstoneDirty(true);
- continue;
- }
- }
- }
++itr;
}
@@ -146,8 +123,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = LinkedPoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
- OtherChunk->SetIsRedstoneDirty(true);
continue;
}
else if (
@@ -161,8 +136,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = LinkedPoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
- OtherChunk->SetIsRedstoneDirty(true);
continue;
}
}
@@ -172,8 +145,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = LinkedPoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
- OtherChunk->SetIsRedstoneDirty(true);
continue;
}
}
@@ -320,6 +291,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int
case E_BLOCK_FENCE_GATE: HandleFenceGate(dataitr->x, dataitr->y, dataitr->z); break;
case E_BLOCK_TNT: HandleTNT(dataitr->x, dataitr->y, dataitr->z); break;
case E_BLOCK_TRAPDOOR: HandleTrapdoor(dataitr->x, dataitr->y, dataitr->z); break;
+ case E_BLOCK_TRAPPED_CHEST: HandleTrappedChest(dataitr->x, dataitr->y, dataitr->z); break;
case E_BLOCK_ACTIVATOR_RAIL:
case E_BLOCK_DETECTOR_RAIL:
@@ -382,18 +354,13 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int
void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
{
- if (
- ((a_BlockX % cChunkDef::Width) <= 1) ||
- ((a_BlockX % cChunkDef::Width) >= 14) ||
- ((a_BlockZ % cChunkDef::Width) <= 1) ||
- ((a_BlockZ % cChunkDef::Width) >= 14)
- ) // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks
+ if (AreCoordsOnChunkBoundary(a_BlockX, a_BlockY, a_BlockZ))
{
// On a chunk boundary, alert all four sides (i.e. at least one neighbouring chunk)
AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
// Pass the original coordinates, because when adding things to our simulator lists, we get the chunk that they are in, and therefore any updates need to preseve their position
- // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordiantes are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries
+ // RedstoneAddBlock to pass both the neighbouring chunk and the chunk which the coordinates are in and +- 2 in GetNeighbour() to accomodate for LinkedPowered blocks being 2 away from chunk boundaries
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 2, a_BlockZ), a_Chunk);
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 2, a_BlockZ), a_Chunk);
RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 2), a_Chunk);
@@ -448,7 +415,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R
if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last)
{
if (
- ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) && // Is it a mechanism or wire? Not block/other torch etc.
+ IsMechanism(Type) && // Is it a mechanism? Not block/other torch etc.
(!Vector3i(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z).Equals(Vector3i(X, Y, Z))) // CAN'T power block is that it is on
)
{
@@ -468,7 +435,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R
{
BLOCKTYPE Type = m_Chunk->GetBlock(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ);
- if ((IsMechanism(Type)) || (Type == E_BLOCK_REDSTONE_WIRE)) // Still can't make a normal block powered though!
+ if (IsMechanism(Type)) // Still can't make a normal block powered though!
{
SetBlockPowered(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ);
}
@@ -780,17 +747,20 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays()
{
for (RepeatersDelayList::iterator itr = m_RepeatersDelayList->begin(); itr != m_RepeatersDelayList->end();)
{
-
if (itr->a_ElapsedTicks >= itr->a_DelayTicks) // Has the elapsed ticks reached the target ticks?
{
int RelBlockX = itr->a_RelBlockPos.x;
int RelBlockY = itr->a_RelBlockPos.y;
int RelBlockZ = itr->a_RelBlockPos.z;
- NIBBLETYPE Meta = m_Chunk->GetMeta(RelBlockX, RelBlockY, RelBlockZ);
+ BLOCKTYPE Block;
+ NIBBLETYPE Meta;
+ m_Chunk->GetBlockTypeMeta(RelBlockX, RelBlockY, RelBlockZ, Block, Meta);
if (itr->ShouldPowerOn)
{
-
- m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta); // For performance
+ if (Block != E_BLOCK_REDSTONE_REPEATER_ON) // For performance
+ {
+ m_Chunk->SetBlock(itr->a_RelBlockPos, E_BLOCK_REDSTONE_REPEATER_ON, Meta);
+ }
switch (Meta & 0x3) // We only want the direction (bottom) bits
{
@@ -820,17 +790,14 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays()
}
}
}
- else
+ else if (Block != E_BLOCK_REDSTONE_REPEATER_OFF)
{
- m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta);
+ m_Chunk->SetBlock(RelBlockX, RelBlockY, RelBlockZ, E_BLOCK_REDSTONE_REPEATER_OFF, Meta);
}
itr = m_RepeatersDelayList->erase(itr);
}
else
{
- // Apparently, incrementing ticks only works reliably here, and not in SimChunk;
- // With a world with lots of redstone, the repeaters simply do not delay
- // I am confounded to say why. Perhaps optimisation failure.
LOGD("Incremented a repeater @ {%i %i %i} | Elapsed ticks: %i | Target delay: %i", itr->a_RelBlockPos.x, itr->a_RelBlockPos.y, itr->a_RelBlockPos.z, itr->a_ElapsedTicks, itr->a_DelayTicks);
itr->a_ElapsedTicks++;
itr++;
@@ -1139,7 +1106,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
else
{
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x0);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
}
@@ -1206,7 +1173,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
@@ -1274,7 +1241,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
}
break;
@@ -1341,7 +1308,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
}
break;
}
@@ -1384,14 +1351,14 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re
{
if (ReverseBlockFace(cBlockTripwireHookHandler::MetadataToDirection(Meta)) == FaceToGoTowards)
{
- // Other hook not facing in opposite direction
+ // Other hook facing in opposite direction - circuit completed!
break;
}
else
{
// Tripwire hook not connected at all, AND away all the power state bits
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
return;
}
}
@@ -1399,7 +1366,7 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re
{
// Tripwire hook not connected at all, AND away all the power state bits
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x3);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
return;
}
}
@@ -1414,7 +1381,51 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re
{
// Connected but not activated, AND away the highest bit
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7) | 0x4);
- WAKE_SIMULATOR_IF_DIRTY(m_Chunk, BlockX, a_RelBlockY, BlockZ);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
+ }
+}
+
+
+
+
+
+void cIncrementalRedstoneSimulator::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+{
+ class cGetTrappedChestPlayers :
+ public cChestCallback
+ {
+ public:
+ cGetTrappedChestPlayers(void) :
+ m_NumberOfPlayers(0)
+ {
+ }
+
+ virtual bool Item(cChestEntity * a_Chest) override
+ {
+ ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST);
+ m_NumberOfPlayers = a_Chest->GetNumberOfPlayers();
+ return (m_NumberOfPlayers <= 0);
+ }
+
+ unsigned char GetPowerLevel(void) const
+ {
+ return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
+ }
+
+ private:
+ int m_NumberOfPlayers;
+
+ } GTCP;
+
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
+ if (m_Chunk->DoWithChestAt(BlockX, a_RelBlockY, BlockZ, GTCP))
+ {
+ SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, GTCP.GetPowerLevel());
+ }
+ else
+ {
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
}
@@ -1881,17 +1892,6 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX;
int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ;
- BLOCKTYPE Block = 0;
- if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block))
- {
- return;
- }
- if (Block == E_BLOCK_AIR)
- {
- // Don't set air, fixes some bugs (wires powering themselves)
- return;
- }
-
cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ);
PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList();
for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list
@@ -1907,16 +1907,31 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
}
}
- PoweredBlocksList * OtherPowered = m_Chunk->GetNeighborChunk(SourceX, SourceZ)->GetRedstoneSimulatorPoweredBlocksList();
- for (PoweredBlocksList::const_iterator itr = OtherPowered->begin(); itr != OtherPowered->end(); ++itr) // Check powered list
+ for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
{
- if (
+ if (
itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) &&
- itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))
+ itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) &&
+ (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE)
)
{
- // Powered wires try to power their source - don't let them!
- return;
+ BLOCKTYPE Block;
+ NIBBLETYPE Meta;
+ Neighbour->GetBlockTypeMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Block, Meta);
+
+ if (Block == E_BLOCK_REDSTONE_WIRE)
+ {
+ if (Meta < a_PowerLevel)
+ {
+ m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it
+ break;
+ }
+ else
+ {
+ // Powered wires try to power their source - don't let them!
+ return;
+ }
+ }
}
}
@@ -1952,11 +1967,6 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered(
{
return;
}
- if (DestBlock == E_BLOCK_AIR)
- {
- // Don't set air, fixes some bugs (wires powering themselves)
- return;
- }
if ((DestBlock == E_BLOCK_REDSTONE_WIRE) && (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE))
{
return;
@@ -2066,6 +2076,43 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in
+void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall)
+{
+ for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();)
+ {
+ if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)))
+ {
+ itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->erase(itr);
+ a_Chunk->SetIsRedstoneDirty(true);
+ continue;
+ }
+ ++itr;
+ }
+ for (LinkedBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->end();)
+ {
+ if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)))
+ {
+ itr = a_Chunk->GetRedstoneSimulatorLinkedBlocksList()->erase(itr);
+ a_Chunk->SetIsRedstoneDirty(true);
+ continue;
+ }
+ ++itr;
+ }
+
+ if (a_IsFirstCall && AreCoordsOnChunkBoundary(a_SourceX, a_SourceY, a_SourceZ))
+ {
+ // +- 2 to accomodate linked powered blocks
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX - 2, a_SourceZ), false);
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX + 2, a_SourceZ), false);
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ - 2), false);
+ SetSourceUnpowered(a_SourceX, a_SourceY, a_SourceZ, a_Chunk->GetNeighborChunk(a_SourceX, a_SourceZ + 2), false);
+ }
+}
+
+
+
+
+
cIncrementalRedstoneSimulator::eRedstoneDirection cIncrementalRedstoneSimulator::GetWireDirection(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
int Dir = REDSTONE_NONE;
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index 6cefdebf2..ce987a60f 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -107,6 +107,8 @@ private:
If this line is complete, it verifies that at least on wire reports an entity is on top (via its meta), and performs its task
*/
void HandleTripwireHook(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
+ /** Handles trapped chests */
+ void HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/* ==================== */
/* ====== CARRIERS ====== */
@@ -114,8 +116,6 @@ private:
void HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Handles repeaters */
void HandleRedstoneRepeater(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState);
- /** Handles delayed updates to Repeaters **/
- void HandleRedstoneRepeaterDelays();
/* ====================== */
/* ====== DEVICES ====== */
@@ -156,6 +156,10 @@ private:
void SetAllDirsAsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char a_PowerLevel = MAX_POWER_LEVEL);
/** Queues a repeater to be powered or unpowered and returns if the m_RepeatersDelayList iterators were invalidated */
bool QueueRepeaterPowerChange(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta, bool ShouldPowerOn);
+ /** Removes a block from the Powered and LinkedPowered lists
+ Used for variable sources such as tripwire hooks, daylight sensors, and trapped chests
+ */
+ void SetSourceUnpowered(int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, cChunk * a_Chunk, bool a_IsFirstCall = true);
/** Returns if a coordinate is powered or linked powered */
bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); }
@@ -174,7 +178,8 @@ private:
/** Returns if a wire is powered
The only diffence between this and a normal AreCoordsPowered is that this function checks for a wire powering another wire */
bool IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel);
-
+ /** Handles delayed updates to repeaters **/
+ void HandleRedstoneRepeaterDelays(void);
/** Returns if lever metadata marks it as emitting power */
bool IsLeverOn(NIBBLETYPE a_BlockMeta);
@@ -186,7 +191,9 @@ private:
/** Returns if a block is viable to be the MiddleBlock of a SetLinkedPowered operation */
inline static bool IsViableMiddleBlock(BLOCKTYPE Block) { return cBlockInfo::FullyOccupiesVoxel(Block); }
- /** Returns if a block is a mechanism (something that accepts power and does something) */
+ /** Returns if a block is a mechanism (something that accepts power and does something)
+ Used by torches to determine if they power a block whilst not standing on the ground
+ */
inline static bool IsMechanism(BLOCKTYPE Block)
{
switch (Block)
@@ -209,6 +216,7 @@ private:
case E_BLOCK_REDSTONE_REPEATER_OFF:
case E_BLOCK_REDSTONE_REPEATER_ON:
case E_BLOCK_POWERED_RAIL:
+ case E_BLOCK_REDSTONE_WIRE:
{
return true;
}
@@ -235,6 +243,7 @@ private:
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
+ case E_BLOCK_TRAPPED_CHEST:
{
return true;
}
@@ -277,6 +286,7 @@ private:
case E_BLOCK_STONE_PRESSURE_PLATE:
case E_BLOCK_TNT:
case E_BLOCK_TRAPDOOR:
+ case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_TRIPWIRE_HOOK:
case E_BLOCK_TRIPWIRE:
case E_BLOCK_WOODEN_BUTTON:
@@ -289,6 +299,16 @@ private:
default: return false;
}
}
+
+ inline static bool AreCoordsOnChunkBoundary(int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ return ( // Are we on a chunk boundary? +- 2 because of LinkedPowered blocks
+ ((a_BlockX % cChunkDef::Width) <= 1) ||
+ ((a_BlockX % cChunkDef::Width) >= 14) ||
+ ((a_BlockZ % cChunkDef::Width) <= 1) ||
+ ((a_BlockZ % cChunkDef::Width) >= 14)
+ );
+ }
};
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 381c6e121..56e1d00e4 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -913,11 +913,13 @@ void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ)
// cChestWindow:
cChestWindow::cChestWindow(cChestEntity * a_Chest) :
- cWindow(wtChest, "Chest"),
+ cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"),
m_World(a_Chest->GetWorld()),
m_BlockX(a_Chest->GetPosX()),
m_BlockY(a_Chest->GetPosY()),
- m_BlockZ(a_Chest->GetPosZ())
+ m_BlockZ(a_Chest->GetPosZ()),
+ m_PrimaryChest(a_Chest),
+ m_SecondaryChest(NULL)
{
m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
@@ -927,7 +929,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
}
@@ -935,11 +937,13 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) :
- cWindow(wtChest, "Double Chest"),
+ cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"),
m_World(a_PrimaryChest->GetWorld()),
m_BlockX(a_PrimaryChest->GetPosX()),
m_BlockY(a_PrimaryChest->GetPosY()),
- m_BlockZ(a_PrimaryChest->GetPosZ())
+ m_BlockZ(a_PrimaryChest->GetPosZ()),
+ m_PrimaryChest(a_PrimaryChest),
+ m_SecondaryChest(a_SecondaryChest)
{
m_SlotAreas.push_back(new cSlotAreaDoubleChest(a_PrimaryChest, a_SecondaryChest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
@@ -951,7 +955,52 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
// Send out the chest-open packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
+}
+
+
+
+
+
+void cChestWindow::OpenedByPlayer(cPlayer & a_Player)
+{
+ int ChunkX, ChunkZ;
+
+ m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() + 1);
+ cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+
+ if (m_SecondaryChest != NULL)
+ {
+ m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1);
+ cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+ }
+
+ cWindow::OpenedByPlayer(a_Player);
+}
+
+
+
+
+
+bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
+{
+ int ChunkX, ChunkZ;
+
+ m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() - 1);
+ cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+
+ if (m_SecondaryChest != NULL)
+ {
+ m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1);
+ cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
+ m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
+ }
+
+ cWindow::ClosedByPlayer(a_Player, a_CanRefuse);
+ return true;
}
@@ -961,7 +1010,7 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
cChestWindow::~cChestWindow()
{
// Send out the chest-close packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST /* Client apparently doesn't mind if we give this to trapped chests as well */);
m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
}
@@ -974,7 +1023,7 @@ cChestWindow::~cChestWindow()
// cDropSpenserWindow:
cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) :
- cWindow(wtDropSpenser, "Dropspenser")
+ cWindow(wtDropSpenser, (a_DropSpenser->GetBlockType() == E_BLOCK_DISPENSER) ? "Dispenser" : "Dropper")
{
m_ShouldDistributeToHotbarFirst = false;
m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this));
diff --git a/src/UI/Window.h b/src/UI/Window.h
index 542dccb88..b170a9d78 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -114,7 +114,7 @@ public:
const cItem & a_ClickedItem
);
- void OpenedByPlayer(cPlayer & a_Player);
+ virtual void OpenedByPlayer(cPlayer & a_Player);
/// Called when a player closes this window; notifies all slot areas. Returns true if close accepted
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse);
@@ -327,10 +327,15 @@ public:
cChestWindow(cChestEntity * a_Chest);
cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest);
~cChestWindow();
+
+ virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
+ virtual void OpenedByPlayer(cPlayer & a_Player) override;
protected:
cWorld * m_World;
int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet
+ cChestEntity * m_PrimaryChest;
+ cChestEntity * m_SecondaryChest;
} ;
diff --git a/src/World.cpp b/src/World.cpp
index 48c3448a3..bc30f16e4 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -389,8 +389,8 @@ void cWorld::InitializeSpawn(void)
IniFile.WriteFile(m_IniFileName);
}
- int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
- BlockToChunk((int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ);
+ int ChunkX = 0, ChunkZ = 0;
+ cChunkDef::BlockToChunk((int)m_SpawnX, (int)m_SpawnZ, ChunkX, ChunkZ);
// For the debugging builds, don't make the server build too much world upon start:
#if defined(_DEBUG) || defined(ANDROID_NDK)
@@ -2191,9 +2191,18 @@ void cWorld::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHa
-void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkZ)
+void cWorld::MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ)
{
- m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkZ);
+ m_ChunkMap->MarkRedstoneDirty(a_ChunkX, a_ChunkZ);
+}
+
+
+
+
+
+void cWorld::MarkChunkDirty(int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty)
+{
+ m_ChunkMap->MarkChunkDirty(a_ChunkX, a_ChunkZ, a_MarkRedstoneDirty);
}
diff --git a/src/World.h b/src/World.h
index 32e64c8e0..4f39ce231 100644
--- a/src/World.h
+++ b/src/World.h
@@ -242,7 +242,8 @@ public:
/** If there is a block entity at the specified coords, sends it to the client specified */
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
- void MarkChunkDirty (int a_ChunkX, int a_ChunkZ);
+ void MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ);
+ void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false);
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ);
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
@@ -635,18 +636,6 @@ public:
// tolua_end
- inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
- {
- // TODO: Use floor() instead of weird if statements
- // Also fix Y
- (void)a_Y; // not unused anymore
- a_ChunkX = a_X/cChunkDef::Width;
- if(a_X < 0 && a_X % cChunkDef::Width != 0) a_ChunkX--;
- a_ChunkY = 0;
- a_ChunkZ = a_Z/cChunkDef::Width;
- if(a_Z < 0 && a_Z % cChunkDef::Width != 0) a_ChunkZ--;
- }
-
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
void SaveAllChunks(void);
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index bff515386..34c47e08d 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -175,10 +175,10 @@ void cNBTChunkSerializer::AddBasicTileEntity(cBlockEntity * a_Entity, const char
-void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
+void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity, BLOCKTYPE a_ChestType)
{
m_Writer.BeginCompound("");
- AddBasicTileEntity(a_Entity, "Chest");
+ AddBasicTileEntity(a_Entity, (a_ChestType == E_BLOCK_CHEST) ? "Chest" : "TrappedChest");
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Entity->GetContents());
m_Writer.EndList();
@@ -817,7 +817,8 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break;
+ case E_BLOCK_TRAPPED_CHEST:
+ case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break;
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index 112afc27e..f73f4ad7d 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -92,7 +92,7 @@ protected:
// Block entities:
void AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID);
- void AddChestEntity (cChestEntity * a_Entity);
+ void AddChestEntity (cChestEntity * a_Entity, BLOCKTYPE a_ChestType);
void AddDispenserEntity(cDispenserEntity * a_Entity);
void AddDropperEntity (cDropperEntity * a_Entity);
void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 9870c144a..1e9fc651d 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -582,7 +582,7 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
}
if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0)
{
- LoadChestFromNBT(a_BlockEntities, a_NBT, Child);
+ LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_CHEST);
}
else if (strncmp(a_NBT.GetData(sID), "Control", a_NBT.GetDataLength(sID)) == 0)
{
@@ -624,6 +624,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
{
LoadDispenserFromNBT(a_BlockEntities, a_NBT, Child);
}
+ else if (strncmp(a_NBT.GetData(sID), "TrappedChest", a_NBT.GetDataLength(sID)) == 0)
+ {
+ LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_TRAPPED_CHEST);
+ }
// TODO: Other block entities
} // for Child - tag children
}
@@ -740,7 +744,7 @@ void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a
-void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType)
{
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
int x, y, z;
@@ -753,7 +757,7 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cPars
{
return; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this
}
- std::auto_ptr Chest(new cChestEntity(x, y, z, m_World));
+ std::auto_ptr Chest(new cChestEntity(x, y, z, m_World, a_ChestType));
LoadItemGridFromNBT(Chest->GetContents(), a_NBT, Items);
a_BlockEntities.push_back(Chest.release());
}
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 7542a828a..6f619fdb8 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -133,7 +133,7 @@ protected:
*/
void LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a_NBT, int a_ItemsTagIdx, int s_SlotOffset = 0);
- void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType);
void LoadDispenserFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadDropperFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFlowerPotFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp
index a853f6ec9..a3ba443fd 100644
--- a/src/WorldStorage/WSSCompact.cpp
+++ b/src/WorldStorage/WSSCompact.cpp
@@ -273,7 +273,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
{
for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
{
- std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World));
+ std::auto_ptr ChestEntity(new cChestEntity(0, 0, 0, a_World, E_BLOCK_CHEST));
if (!ChestEntity->LoadFromJson(*itr))
{
LOGWARNING("ERROR READING CHEST FROM JSON!" );
--
cgit v1.2.3
From 756c45d07bbf7e700caab660adf31bfd9f08b7e5 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 7 Jul 2014 21:12:25 +0100
Subject: Fixed compilation and pressure plates
---
src/Simulator/IncrementalRedstoneSimulator.cpp | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index e46eb0429..d96c66c8b 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -101,8 +101,6 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) ||
((Block == E_BLOCK_DETECTOR_RAIL) && ((Meta & 0x08) == 0)) ||
(((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) ||
- (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) ||
- (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0)) ||
((Block == E_BLOCK_TRIPWIRE_HOOK) && ((Meta & 0x08) == 0))
)
{
@@ -129,9 +127,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
// Things that can send power through a block but which depends on meta
((Block == E_BLOCK_REDSTONE_WIRE) && (Meta == 0)) ||
((Block == E_BLOCK_LEVER) && !IsLeverOn(Meta)) ||
- (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta))) ||
- (((Block == E_BLOCK_STONE_PRESSURE_PLATE) || (Block == E_BLOCK_WOODEN_PRESSURE_PLATE)) && (Meta == 0)) ||
- (((Block == E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE) || (Block == E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE)) && (Meta == 0))
+ (((Block == E_BLOCK_STONE_BUTTON) || (Block == E_BLOCK_WOODEN_BUTTON)) && (!IsButtonOn(Meta)))
)
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
@@ -1241,7 +1237,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
@@ -1308,7 +1304,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
- SetSourceUnpowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk);
+ SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
}
break;
}
@@ -1907,7 +1903,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
}
}
- for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
+ for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
{
if (
itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) &&
--
cgit v1.2.3
From 7c7501abc5345ec4eddd030ab4649b05354002c3 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 7 Jul 2014 21:14:15 +0100
Subject: Added extra space before comments
---
src/Entities/ProjectileEntity.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 334973833..0bb34019e 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -69,15 +69,15 @@ protected:
if (cBlockInfo::IsSolid(a_BlockType))
{
// The projectile hit a solid block, calculate the exact hit coords:
- cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit
- const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit
- const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit
- double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs
- eBlockFace Face; // Face hit
+ cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); // Bounding box of the block hit
+ const Vector3d LineStart = m_Projectile->GetPosition(); // Start point for the imaginary line that goes through the block hit
+ const Vector3d LineEnd = LineStart + m_Projectile->GetSpeed(); // End point for the imaginary line that goes through the block hit
+ double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs
+ eBlockFace Face; // Face hit
if (bb.CalcLineIntersection(LineStart, LineEnd, LineCoeff, Face))
{
- Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block
+ Vector3d Intersection = LineStart + m_Projectile->GetSpeed() * LineCoeff; // Point where projectile goes into the hit block
if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile, a_BlockX, a_BlockY, a_BlockZ, Face, &Intersection))
{
--
cgit v1.2.3
From 164ffe50adbadd4bc123f11d585fef5c447d776e Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Tue, 8 Jul 2014 12:34:39 +0100
Subject: Made things consistent
---
src/BlockEntities/BlockEntity.cpp | 9 +++++----
src/WorldStorage/NBTChunkSerializer.cpp | 6 ++++--
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index 1e2a176ef..1deddb0e9 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -27,22 +27,23 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
{
switch (a_BlockType)
{
- case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_TRAPPED_CHEST:
case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
+ case E_BLOCK_LIT_FURNACE:
+ case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+
+ case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
- case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
}
LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 34c47e08d..1654153ff 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -818,12 +818,14 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
switch (a_Entity->GetBlockType())
{
case E_BLOCK_TRAPPED_CHEST:
- case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_LIT_FURNACE:
+ case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
+
case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break;
case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
--
cgit v1.2.3
From f2419afac5e138d64cbe968aad5a0838809f997c Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 8 Jul 2014 23:11:06 +0200
Subject: Updated generator prefabs to current Gallery contents.
---
src/Generating/Prefabs/AlchemistVillagePrefabs.cpp | 10 +++++-----
src/Generating/Prefabs/JapaneseVillagePrefabs.cpp | 2 +-
src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 3 ++-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp
index 5cb864d53..976f8490e 100644
--- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp
+++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp
@@ -58,9 +58,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] =
"o: 50: 4\n" /* torch */
"p: 13: 0\n" /* gravel */
"q: 5: 0\n" /* wood */
- "r: 96:12\n" /* trapdoor */
+ "r: 96: 8\n" /* trapdoor */
"s:128: 5\n" /* sandstonestairs */
- "t:107: 0\n" /* fencegate */
+ "t:107: 2\n" /* fencegate */
"u:128: 4\n" /* sandstonestairs */
"v:134: 3\n" /* 134 */
"w: 85: 0\n" /* fence */
@@ -288,7 +288,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] =
"d: 13: 0\n" /* gravel */
"e: 5: 0\n" /* wood */
"f:128: 5\n" /* sandstonestairs */
- "g:107: 0\n" /* fencegate */
+ "g:107: 2\n" /* fencegate */
"h:128: 4\n" /* sandstonestairs */
"i:134: 1\n" /* 134 */
"j:134: 3\n" /* 134 */
@@ -298,7 +298,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] =
"n:134: 5\n" /* 134 */
"o:134: 7\n" /* 134 */
"p:134: 4\n" /* 134 */
- "q:107: 5\n" /* fencegate */
+ "q:107: 1\n" /* fencegate */
"r: 64: 1\n" /* wooddoorblock */
"s: 65: 3\n" /* ladder */
"t: 50: 3\n" /* torch */
@@ -2195,7 +2195,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] =
0,
// MoveToGround:
- false,
+ true,
}, // LittleHouse8
diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp
index 79f7a5272..d22153d87 100644
--- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp
+++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp
@@ -294,7 +294,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] =
0,
// MoveToGround:
- false,
+ true,
}, // Farm
diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
index 9e5e06769..bba493bf1 100644
--- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
+++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
@@ -356,6 +356,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
"e: 8: 0\n" /* water */
"f: 50: 5\n" /* torch */
"g: 59: 7\n" /* crops */
+ "h:111: 0\n" /* lilypad */
"m: 19: 0\n" /* sponge */,
// Block data:
@@ -407,7 +408,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 3 */ ".g.......gg.gg."
/* 4 */ ".gg..g...gg.gg."
/* 5 */ ".gg..g...gg.gg."
- /* 6 */ "..g..g...gg.gg."
+ /* 6 */ "..g..g...gghgg."
/* 7 */ "..g.g....gg.gg."
/* 8 */ "f.....f.f.....f"
--
cgit v1.2.3
From 3615bf825b53d3e192ad7fe6d047bd713bc00394 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Wed, 9 Jul 2014 14:30:06 +0200
Subject: Added inventory number click.
---
src/UI/SlotArea.cpp | 38 ++++++++++++++++++++++++++++++++++++++
src/UI/SlotArea.h | 6 +++++-
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 68ec78930..93beca9c6 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -77,6 +77,19 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
DropClicked(a_Player, a_SlotNum, (a_ClickAction == caCtrlDropKey));
return;
}
+ case caNumber1:
+ case caNumber2:
+ case caNumber3:
+ case caNumber4:
+ case caNumber5:
+ case caNumber6:
+ case caNumber7:
+ case caNumber8:
+ case caNumber9:
+ {
+ NumberClicked(a_Player, a_SlotNum, a_ClickAction);
+ return;
+ }
default:
{
break;
@@ -283,6 +296,31 @@ void cSlotArea::DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack)
+void cSlotArea::NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction)
+{
+ if ((a_ClickAction < caNumber1) || (a_ClickAction > caNumber9))
+ {
+ return;
+ }
+
+ int HotbarSlot = (int)a_ClickAction - (int)caNumber1;
+ cItem ItemInHotbar(a_Player.GetInventory().GetHotbarSlot(HotbarSlot));
+ cItem ItemInSlot(*GetSlot(a_SlotNum, a_Player));
+
+ // The items are equal. Do nothing.
+ if (ItemInHotbar.IsEqual(ItemInSlot))
+ {
+ return;
+ }
+
+ a_Player.GetInventory().SetHotbarSlot(HotbarSlot, ItemInSlot);
+ SetSlot(a_SlotNum, a_Player, ItemInHotbar);
+}
+
+
+
+
+
void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
{
UNUSED(a_Player);
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index 03f538956..c40d65e0e 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -56,6 +56,9 @@ public:
/** Called from Clicked when the action is a drop click. */
virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack);
+ /** Called from Clicked when the action is a number click. */
+ virtual void NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction);
+
/// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
virtual void OnPlayerAdded(cPlayer & a_Player);
@@ -242,6 +245,7 @@ public:
// Distributing items into this area is completely disabled
virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
+
protected:
/// Maps player's EntityID -> current recipe; not a std::map because cCraftingGrid needs proper constructor params
typedef std::list > cRecipeMap;
@@ -257,7 +261,7 @@ protected:
/** Handles a drop-click in the result slot. */
void DropClickedResult(cPlayer & a_Player);
-
+
/// Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player
void UpdateRecipe(cPlayer & a_Player);
--
cgit v1.2.3
From 0d88e71d182e68af8e8c40b7993b0e08f78cf13a Mon Sep 17 00:00:00 2001
From: Howaner
Date: Wed, 9 Jul 2014 14:35:01 +0200
Subject: Removed unused include line.
---
src/UI/SlotArea.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 93beca9c6..db05859d2 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -15,7 +15,6 @@
#include "../Root.h"
#include "../FastRandom.h"
#include "../BlockArea.h"
-#include "polarssl/camellia.h"
--
cgit v1.2.3
From 98950af634cca62af08ddf8c07b77f46165578a8 Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Wed, 9 Jul 2014 16:53:01 +0200
Subject: Fixed Bucket placing
---
src/Items/ItemBucket.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 68c89dd85..fa98587ea 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -41,7 +41,7 @@ public:
bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
{
- if (a_BlockFace > 0)
+ if (a_BlockFace < 0)
{
return false;
}
--
cgit v1.2.3
From 74b6b398e7e5a2384f398b7dceaf45716bc70b6f Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 9 Jul 2014 19:56:50 +0100
Subject: Fixed arrow collection animation
* Fixed piston extension non-solidness
---
src/BlockInfo.cpp | 1 -
src/Entities/ArrowEntity.cpp | 24 +++---------------------
src/Entities/Pickup.cpp | 2 +-
src/World.cpp | 9 ---------
src/World.h | 1 -
5 files changed, 4 insertions(+), 33 deletions(-)
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 16314290a..9a953e396 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -365,7 +365,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
- a_Info[E_BLOCK_PISTON_EXTENSION ].m_IsSolid = false;
a_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_RAIL ].m_IsSolid = false;
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 47a0876fc..d59088e72 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -106,14 +106,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
// Broadcast successful hit sound
- m_World->BroadcastSoundEffect(
- "random.successful_hit",
- (int)std::floor(GetPosX() * 8.0),
- (int)std::floor(GetPosY() * 8.0),
- (int)std::floor(GetPosZ() * 8.0),
- 0.5f,
- 0.75f + ((float)((GetUniqueID() * 23) % 32)) / 64.0f
- );
+ GetWorld()->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
@@ -136,21 +129,10 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest)
return;
}
}
-
- // TODO: BroadcastCollectPickup needs a cPickup, which we don't have
- // m_World->BroadcastCollectPickup(*this, *a_Dest);
+ GetWorld()->BroadcastCollectEntity(*this, *a_Dest);
+ GetWorld()->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsCollected = true;
-
- cFastRandom Random;
- m_World->BroadcastSoundEffect(
- "random.pop",
- (int)std::floor(GetPosX() * 8.0),
- (int)std::floor(GetPosY() * 8),
- (int)std::floor(GetPosZ() * 8),
- 0.2F,
- ((Random.NextFloat(1.0F) - Random.NextFloat(1.0F)) * 0.7F + 1.0F) * 2.0F
- );
}
}
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 10b6bbd5c..24fa591da 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -224,7 +224,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
}
m_Item.m_ItemCount -= NumAdded;
- m_World->BroadcastCollectPickup(*this, *a_Dest);
+ m_World->BroadcastCollectEntity(*this, *a_Dest);
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
if (m_Item.m_ItemCount <= 0)
diff --git a/src/World.cpp b/src/World.cpp
index 48c3448a3..a6607de12 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1886,15 +1886,6 @@ void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_
-void cWorld::BroadcastCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude)
-{
- m_ChunkMap->BroadcastCollectEntity(a_Pickup, a_Player, a_Exclude);
-}
-
-
-
-
-
void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
m_ChunkMap->BroadcastDestroyEntity(a_Entity, a_Exclude);
diff --git a/src/World.h b/src/World.h
index 32e64c8e0..476a49739 100644
--- a/src/World.h
+++ b/src/World.h
@@ -207,7 +207,6 @@ public:
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
- void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude = NULL);
--
cgit v1.2.3
From da1d946b2b6cbb5d3e66c78adc09a4c472e04078 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 9 Jul 2014 22:04:26 +0100
Subject: Fixed bow charge
---
src/Items/ItemBow.h | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index 940338d0f..185f17fee 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -55,7 +55,7 @@ public:
// Too little force, ignore the shot
return;
}
- Force = std::max(Force, 1.0);
+ Force = std::min(Force, 1.0);
// Create the arrow entity:
cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2);
@@ -70,16 +70,7 @@ public:
return;
}
- cFastRandom Random;
- a_Player->GetWorld()->BroadcastSoundEffect(
- "random.bow",
- (int)std::floor(a_Player->GetPosX() * 8.0),
- (int)std::floor(a_Player->GetPosY() * 8.0),
- (int)std::floor(a_Player->GetPosZ() * 8.0),
- 1.0F,
- 1.0F / (Random.NextFloat(1.0F) * 0.4F + 1.2F) + (float)Force * 0.5F
- );
-
+ a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force);
if (!a_Player->IsGameModeCreative())
{
a_Player->UseEquippedItem();
--
cgit v1.2.3
From a6d30a72544a626680eec6facf5b7a67ebb8fda5 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 12:20:55 +0200
Subject: Removed lilypad from plains village prefabs.
---
src/Generating/Prefabs/PlainsVillagePrefabs.cpp | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
index bba493bf1..bad8dae74 100644
--- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
+++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp
@@ -356,7 +356,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
"e: 8: 0\n" /* water */
"f: 50: 5\n" /* torch */
"g: 59: 7\n" /* crops */
- "h:111: 0\n" /* lilypad */
+ "h: 59: 0\n" /* crops */
+ "i: 59: 1\n" /* crops */
"m: 19: 0\n" /* sponge */,
// Block data:
@@ -404,12 +405,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* * 012345678901234 */
/* 0 */ "f.....f.f.....f"
/* 1 */ ".gg.gg...gg.gg."
- /* 2 */ ".g...g...gg.gg."
- /* 3 */ ".g.......gg.gg."
- /* 4 */ ".gg..g...gg.gg."
- /* 5 */ ".gg..g...gg.gg."
- /* 6 */ "..g..g...gghgg."
- /* 7 */ "..g.g....gg.gg."
+ /* 2 */ ".gh.hg...gg.gg."
+ /* 3 */ ".gh.ih...gg.gg."
+ /* 4 */ ".gg.hg...gg.gg."
+ /* 5 */ ".gg.hg...gg.gg."
+ /* 6 */ ".ig.hg...gg.gg."
+ /* 7 */ ".hg.gh...gg.gg."
/* 8 */ "f.....f.f.....f"
// Level 4
--
cgit v1.2.3
From ce670accc9740ad5f096658be9b0a39b4aabf0cc Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 12:37:21 +0200
Subject: Fixed Vector3.h compilation in MSVC2008.
---
src/Vector3.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/Vector3.h b/src/Vector3.h
index 9e855b8af..0a0968c59 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -316,6 +316,15 @@ protected:
+template <> Vector3 Vector3::Floor(void) const
+{
+ return *this;
+}
+
+
+
+
+
template
const double Vector3::EPS = 0.000001;
--
cgit v1.2.3
From db759891578c1cf4ce7f6d577b73fd1981ed502e Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 12:46:09 +0200
Subject: Fixed a missing "inline" keyword.
---
src/Vector3.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Vector3.h b/src/Vector3.h
index 0a0968c59..c175bf135 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -316,7 +316,7 @@ protected:
-template <> Vector3 Vector3::Floor(void) const
+template <> inline Vector3 Vector3::Floor(void) const
{
return *this;
}
--
cgit v1.2.3
From a11ad977ce9465c6c37050f7b9a82f1884645a34 Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Thu, 10 Jul 2014 16:10:42 +0200
Subject: Fixed Bucket Placing
---
src/Items/ItemBucket.h | 63 +++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 57 insertions(+), 6 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index fa98587ea..41b7c82bc 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -41,7 +41,7 @@ public:
bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
{
- if (a_BlockFace < 0)
+ if (a_BlockFace > 0)
{
return false;
}
@@ -95,18 +95,24 @@ public:
bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock)
{
- if (a_BlockFace < 0)
+ if (a_BlockFace > 0)
{
return false;
}
+
+ Vector3i BlockPos;
+ if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos))
+ {
+ return false;
+ }
- BLOCKTYPE CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos);
bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
if (!CanWashAway)
{
// The block pointed at cannot be washed away, so put fluid on top of it / on its sides
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- CurrentBlock = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ //AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace);
+ CurrentBlock = a_World->GetBlock(BlockPos);
}
if (
!CanWashAway &&
@@ -149,7 +155,7 @@ public:
}
}
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_FluidBlock, 0);
+ a_World->SetBlock(BlockPos.x, BlockPos.y, BlockPos.z, a_FluidBlock, 0);
return true;
}
@@ -201,5 +207,50 @@ public:
BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z);
return true;
}
+
+
+ bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos)
+ {
+ class cCallbacks :
+ public cBlockTracer::cCallbacks
+ {
+ public:
+ Vector3i m_Pos;
+ bool m_HasHitLastBlock;
+
+
+ cCallbacks(void) :
+ m_HasHitLastBlock(false)
+ {
+ }
+
+ virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
+ {
+ if (a_BlockType != E_BLOCK_AIR)
+ {
+ m_HasHitLastBlock = true;
+ return true;
+ }
+
+ m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ);
+
+ return false;
+ }
+ } Callbacks;
+ cLineBlockTracer Tracer(*a_World, Callbacks);
+ Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector());
+ Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
+
+ Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z);
+
+ if (!Callbacks.m_HasHitLastBlock)
+ {
+ return false;
+ }
+
+
+ BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z);
+ return true;
+ }
};
--
cgit v1.2.3
From 47ceb9e79db2a30dd5b5e48dd28f9c6f14ed2fc3 Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Thu, 10 Jul 2014 16:36:28 +0200
Subject: Maybe fixed whitespaces
---
src/Items/ItemBucket.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 41b7c82bc..5c8d5f741 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -105,7 +105,7 @@ public:
{
return false;
}
-
+
BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos);
bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
if (!CanWashAway)
--
cgit v1.2.3
From 944c04a209492826365b3785ccf1ed1fc70e122c Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Thu, 10 Jul 2014 16:38:19 +0200
Subject: Maybe fixed whitespaces
---
src/Items/ItemBucket.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 5c8d5f741..ab884ced6 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -99,13 +99,13 @@ public:
{
return false;
}
-
- Vector3i BlockPos;
- if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos))
- {
- return false;
- }
-
+
+ Vector3i BlockPos;
+ if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos))
+ {
+ return false;
+ }
+
BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos);
bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
if (!CanWashAway)
--
cgit v1.2.3
From a8efb620881cd744cfd3cc74316a39bfec80b897 Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Thu, 10 Jul 2014 17:46:07 +0200
Subject: Changes
---
src/Items/ItemBucket.h | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index ab884ced6..b31266f35 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -100,19 +100,19 @@ public:
return false;
}
+ BLOCKTYPE CurrentBlock;
Vector3i BlockPos;
- if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos))
+ if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock))
{
return false;
}
- BLOCKTYPE CurrentBlock = a_World->GetBlock(BlockPos);
bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
if (!CanWashAway)
{
// The block pointed at cannot be washed away, so put fluid on top of it / on its sides
- //AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace);
- CurrentBlock = a_World->GetBlock(BlockPos);
+ // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace);
+ // CurrentBlock = a_World->GetBlock(BlockPos);
}
if (
!CanWashAway &&
@@ -161,7 +161,7 @@ public:
}
- bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos)
+ bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos)
{
class cCallbacks :
public cBlockTracer::cCallbacks
@@ -204,19 +204,20 @@ public:
}
- BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z);
+ a_BlockPos = Callbacks.m_Pos;
return true;
}
- bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & BlockPos)
+ bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
{
class cCallbacks :
public cBlockTracer::cCallbacks
{
public:
- Vector3i m_Pos;
- bool m_HasHitLastBlock;
+ Vector3i m_Pos;
+ bool m_HasHitLastBlock;
+ BLOCKTYPE m_LastBlock;
cCallbacks(void) :
@@ -226,15 +227,16 @@ public:
virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
{
- if (a_BlockType != E_BLOCK_AIR)
- {
- m_HasHitLastBlock = true;
- return true;
- }
-
- m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ);
-
- return false;
+ if (a_BlockType != E_BLOCK_AIR)
+ {
+ m_HasHitLastBlock = true;
+ return true;
+ }
+
+ m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ);
+ m_LastBlock = a_BlockType;
+
+ return false;
}
} Callbacks;
@@ -249,8 +251,8 @@ public:
return false;
}
-
- BlockPos.Set(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z);
+ a_BlockPos = Callbacks.m_Pos;
+ a_BlockType = Callbacks.m_LastBlock;
return true;
}
};
--
cgit v1.2.3
From 9e22f46b15d4c92bfbfdd5fb23d7530348f1d534 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 18:18:32 +0200
Subject: Implemented support for forced chunk ticking.
Fixes #1160.
---
src/Chunk.cpp | 30 ++++++++++++++++++++++++++++--
src/Chunk.h | 30 ++++++++++++++++++++++++++----
src/ChunkMap.cpp | 20 ++++++++++++++++++--
src/ChunkMap.h | 7 +++++++
src/World.cpp | 9 +++++++++
src/World.h | 7 +++++++
6 files changed, 95 insertions(+), 8 deletions(-)
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 0fee40cac..3f5165b7b 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -87,7 +87,8 @@ cChunk::cChunk(
m_NeighborZM(a_NeighborZM),
m_NeighborZP(a_NeighborZP),
m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()),
- m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData())
+ m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()),
+ m_AlwaysTicked(0)
{
if (a_NeighborXM != NULL)
{
@@ -1641,6 +1642,31 @@ cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cChunk::ShouldBeTicked(void) const
+{
+ return (HasAnyClients() || (m_AlwaysTicked > 0));
+}
+
+
+
+
+
+void cChunk::SetAlwaysTicked(bool a_AlwaysTicked)
+{
+ if (a_AlwaysTicked)
+ {
+ m_AlwaysTicked += 1;
+ }
+ else
+ {
+ m_AlwaysTicked -= 1;
+ }
+}
+
+
+
+
+
void cChunk::UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z)
{
cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z);
@@ -1852,7 +1878,7 @@ bool cChunk::HasClient( cClientHandle* a_Client )
-bool cChunk::HasAnyClients(void)
+bool cChunk::HasAnyClients(void) const
{
return !m_LoadedByClient.empty();
}
diff --git a/src/Chunk.h b/src/Chunk.h
index e9d964e05..ededf62cd 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -200,11 +200,16 @@ public:
void SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client);
/** Adds a client to the chunk; returns true if added, false if already there */
- bool AddClient (cClientHandle* a_Client );
+ bool AddClient(cClientHandle * a_Client);
- void RemoveClient (cClientHandle* a_Client );
- bool HasClient (cClientHandle* a_Client );
- bool HasAnyClients(void); // Returns true if theres any client in the chunk; false otherwise
+ /** Removes the specified client from the chunk; ignored if client not in chunk. */
+ void RemoveClient(cClientHandle * a_Client);
+
+ /** Returns true if the specified client is present in this chunk. */
+ bool HasClient(cClientHandle * a_Client);
+
+ /** Returns true if theres any client in the chunk; false otherwise */
+ bool HasAnyClients(void) const;
void AddEntity(cEntity * a_Entity);
void RemoveEntity(cEntity * a_Entity);
@@ -390,6 +395,17 @@ public:
cBlockEntity * GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
cBlockEntity * GetBlockEntity(const Vector3i & a_BlockPos) { return GetBlockEntity(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z); }
+
+ /** Returns true if the chunk should be ticked in the tick-thread.
+ Checks if there are any clients and if the always-tick flag is set */
+ bool ShouldBeTicked(void) const;
+
+ /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter.
+ If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
+ whether it has any clients or not.
+ This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
+ as at least one requests is active the chunk will be ticked). */
+ void SetAlwaysTicked(bool a_AlwaysTicked);
private:
@@ -462,6 +478,12 @@ private:
/** Indicates if simulate-once blocks should be updated by the redstone simulator */
bool m_IsRedstoneDirty;
+
+ /** If greater than zero, the chunk is ticked even if it has no clients.
+ Manipulated by the SetAlwaysTicked() function, allows for nested calls of the function.
+ This is the support for plugin-accessible chunk tick forcing. */
+ int m_AlwaysTicked;
+
// Pick up a random block of this chunk
void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z);
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index c9fb0b59e..687c0824f 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -2674,6 +2674,20 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+ if (Chunk != NULL)
+ {
+ Chunk->SetAlwaysTicked(a_AlwaysTicked);
+ }
+}
+
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cChunkMap::cChunkLayer:
@@ -2788,12 +2802,14 @@ void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner)
+
+
void cChunkMap::cChunkLayer::Tick(float a_Dt)
{
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
{
- // Only tick chunks that are valid and have clients:
- if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients())
+ // Only tick chunks that are valid and should be ticked:
+ if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->ShouldBeTicked())
{
m_Chunks[i]->Tick(a_Dt);
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 433516490..b8870dfca 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -339,6 +339,13 @@ public:
/** Returns the CS for locking the chunkmap; only cWorld::cLock may use this function! */
cCriticalSection & GetCS(void) { return m_CSLayers; }
+
+ /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
+ If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
+ whether it has any clients or not.
+ This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
+ as at least one requests is active the chunk will be ticked). */
+ void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked);
private:
diff --git a/src/World.cpp b/src/World.cpp
index a6607de12..f91a15260 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -3033,6 +3033,15 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul
+void cWorld::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
+{
+ m_ChunkMap->SetChunkAlwaysTicked(a_ChunkX, a_ChunkZ, a_AlwaysTicked);
+}
+
+
+
+
+
cRedstoneSimulator * cWorld::InitializeRedstoneSimulator(cIniFile & a_IniFile)
{
AString SimulatorName = a_IniFile.GetValueSet("Physics", "RedstoneSimulator", "");
diff --git a/src/World.h b/src/World.h
index 476a49739..f903ff5be 100644
--- a/src/World.h
+++ b/src/World.h
@@ -772,6 +772,13 @@ public:
/** Get the current darkness level based on the time */
NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; }
+
+ /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
+ If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
+ whether it has any clients or not.
+ This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
+ as at least one requests is active the chunk will be ticked). */
+ void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
private:
--
cgit v1.2.3
From 3b7e0969b98ecbd1d499a9ac2edd22a619ae5591 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 18:19:05 +0200
Subject: Debuggers: Added forced chunk ticking test.
Ref.: #1160
---
MCServer/Plugins/Debuggers/Debuggers.lua | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index deb6a720b..918204deb 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -31,6 +31,8 @@ function Initialize(Plugin)
PM:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage);
PM:AddHook(cPluginManager.HOOK_PLAYER_JOINED, OnPlayerJoined);
PM:AddHook(cPluginManager.HOOK_PROJECTILE_HIT_BLOCK, OnProjectileHitBlock);
+ PM:AddHook(cPluginManager.HOOK_CHUNK_UNLOADING, OnChunkUnloading);
+ PM:AddHook(cPluginManager.HOOK_WORLD_STARTED, OnWorldStarted);
-- _X: Disabled so that the normal operation doesn't interfere with anything
-- PM:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated);
@@ -1382,6 +1384,7 @@ end
function OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockHitPos)
+ -- Test projectile hooks by setting the blocks they hit on fire:
local BlockX, BlockY, BlockZ = AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)
local World = a_Projectile:GetWorld()
@@ -1391,3 +1394,28 @@ end
+
+function OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ)
+ -- Do not let chunk [0, 0] unload, so that it continues ticking [cWorld:SetChunkAlwaysTicked() test]
+ if ((a_ChunkX == 0) and (a_ChunkZ == 0)) then
+ return true
+ end
+end
+
+
+
+
+
+function OnWorldStarted(a_World)
+ -- Make the chunk [0, 0] in every world keep ticking [cWorld:SetChunkAlwaysTicked() test]
+ a_World:ChunkStay({{0, 0}}, nil,
+ function()
+ -- The chunk is loaded, make it always tick:
+ a_World:SetChunkAlwaysTicked(0, 0, true)
+ end
+ )
+end
+
+
+
+
--
cgit v1.2.3
From d790a45c5025e33712d8dd21f9349716ae4ee7d1 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 18:28:20 +0200
Subject: APIDump: Documented cWorld:SetChunkAlwaysTicked.
Ref.: #1160
---
MCServer/Plugins/APIDump/APIDesc.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index baa9f0f37..ea9f38db4 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2340,6 +2340,7 @@ end
{ Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." },
{ Params = "{{Vector3i|BlockCoords}}, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." },
},
+ SetChunkAlwaysTicked = { Params = "ChunkX, ChunkZ, IsAlwaysTicked", Return = "", Notes = "Sets the chunk to always be ticked even when it doesn't contain any clients. IsAlwaysTicked set to true turns forced ticking on, set to false turns it off. Every call with 'true' should be paired with a later call with 'false', otherwise the ticking won't stop. Multiple actions can request ticking independently, the ticking will continue until the last call with 'false'. Note that when the chunk unloads, it loses the value of this flag." },
SetNextBlockTick = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Sets the blockticking to start at the specified block in the next tick." },
SetCommandBlockCommand = { Params = "BlockX, BlockY, BlockZ, Command", Return = "bool", Notes = "Sets the command to be executed in a command block at the specified coordinates. Returns if command was changed." },
SetCommandBlocksEnabled = { Params = "IsEnabled (bool)", Return = "", Notes = "Sets whether command blocks should be enabled on the (entire) server." },
--
cgit v1.2.3
From 729cc7f6ffd34724e6c9d5e3a4367ba6b2c48241 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 10 Jul 2014 23:04:33 +0200
Subject: Fixed style consistency.
---
src/Chunk.cpp | 121 ++++++++++++++++++++++++++++++----------------------------
src/Chunk.h | 4 +-
2 files changed, 64 insertions(+), 61 deletions(-)
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 3f5165b7b..1e80eb61b 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -464,7 +464,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
-void cChunk::getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ)
+void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z,int a_MaxX, int a_MaxY, int a_MaxZ)
{
ASSERT(a_MaxX * a_MaxY * a_MaxZ * 8 < 0x00ffffff);
int Random = m_World->GetTickRandomNumber(0x00ffffff);
@@ -480,12 +480,12 @@ void cChunk::getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a
-void cChunk::getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z)
+void cChunk::GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z)
{
// MG TODO : check if this kind of optimization (only one random call) is still needed
// MG TODO : if so propagate it
- getThreeRandomNumber(a_X, a_Y, a_Z, Width, Height-2, Width);
+ GetThreeRandomNumbers(a_X, a_Y, a_Z, Width, Height - 2, Width);
a_Y++;
}
@@ -495,65 +495,68 @@ void cChunk::getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z)
void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
{
- int Center_X,Center_Y,Center_Z;
- getRandomBlockCoords(Center_X,Center_Y,Center_Z);
-
- BLOCKTYPE PackCenterBlock = GetBlock(Center_X, Center_Y, Center_Z);
- if (a_MobSpawner.CheckPackCenter(PackCenterBlock))
- {
- a_MobSpawner.NewPack();
- int NumberOfTries = 0;
- int NumberOfSuccess = 0;
- int MaxNbOfSuccess = 4; // this can be changed during the process for Wolves and Ghass
- while (NumberOfTries < 12 && NumberOfSuccess < MaxNbOfSuccess)
- {
- const int HorizontalRange = 20; // MG TODO : relocate
- const int VerticalRange = 0; // MG TODO : relocate
- int Try_X, Try_Y, Try_Z;
- getThreeRandomNumber(Try_X, Try_Y, Try_Z, 2*HorizontalRange+1 , 2*VerticalRange+1 , 2*HorizontalRange+1);
- Try_X -= HorizontalRange;
- Try_Y -= VerticalRange;
- Try_Z -= HorizontalRange;
- Try_X += Center_X;
- Try_Y += Center_Y;
- Try_Z += Center_Z;
-
- ASSERT(Try_Y > 0);
- ASSERT(Try_Y < cChunkDef::Height-1);
-
- EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z);
- // MG TODO :
- // Moon cycle (for slime)
- // check player and playerspawn presence < 24 blocks
- // check mobs presence on the block
-
- // MG TODO : check that "Level" really means Y
-
- /*
- NIBBLETYPE SkyLight = 0;
-
- NIBBLETYPE BlockLight = 0;
- */
+ int CenterX, CenterY, CenterZ;
+ GetRandomBlockCoords(CenterX, CenterY, CenterZ);
- if (IsLightValid())
- {
- cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess);
- if (newMob)
- {
- int WorldX, WorldY, WorldZ;
- PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ);
- double ActualX = WorldX + 0.5;
- double ActualZ = WorldZ + 0.5;
- newMob->SetPosition(ActualX, WorldY, ActualZ);
- LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ);
- NumberOfSuccess++;
- }
- }
-
- NumberOfTries++;
- }
+ BLOCKTYPE PackCenterBlock = GetBlock(CenterX, CenterY, CenterZ);
+ if (!a_MobSpawner.CheckPackCenter(PackCenterBlock))
+ {
+ return;
}
+
+ a_MobSpawner.NewPack();
+ int NumberOfTries = 0;
+ int NumberOfSuccess = 0;
+ int MaxNbOfSuccess = 4; // This can be changed during the process for Wolves and Ghasts
+ while ((NumberOfTries < 12) && (NumberOfSuccess < MaxNbOfSuccess))
+ {
+ const int HorizontalRange = 20; // MG TODO : relocate
+ const int VerticalRange = 0; // MG TODO : relocate
+ int TryX, TryY, TryZ;
+ GetThreeRandomNumbers(TryX, TryY, TryZ, 2 * HorizontalRange + 1, 2 * VerticalRange + 1, 2 * HorizontalRange + 1);
+ TryX -= HorizontalRange;
+ TryY -= VerticalRange;
+ TryZ -= HorizontalRange;
+ TryX += CenterX;
+ TryY += CenterY;
+ TryZ += CenterZ;
+
+ ASSERT(TryY > 0);
+ ASSERT(TryY < cChunkDef::Height - 1);
+
+ EMCSBiome Biome = m_ChunkMap->GetBiomeAt(TryX, TryZ);
+ // MG TODO :
+ // Moon cycle (for slime)
+ // check player and playerspawn presence < 24 blocks
+ // check mobs presence on the block
+ // MG TODO : check that "Level" really means Y
+
+ /*
+ NIBBLETYPE SkyLight = 0;
+
+ NIBBLETYPE BlockLight = 0;
+ */
+
+ NumberOfTries++;
+ if (!IsLightValid())
+ {
+ continue;
+ }
+
+ cEntity * newMob = a_MobSpawner.TryToSpawnHere(this, TryX, TryY, TryZ, Biome, MaxNbOfSuccess);
+ if (newMob == NULL)
+ {
+ continue;
+ }
+ int WorldX, WorldY, WorldZ;
+ PositionToWorldPosition(TryX, TryY, TryZ, WorldX, WorldY, WorldZ);
+ double ActualX = WorldX + 0.5;
+ double ActualZ = WorldZ + 0.5;
+ newMob->SetPosition(ActualX, WorldY, ActualZ);
+ LOGD("Spawning %s #%i at {%d, %d, %d}", newMob->GetClass(), newMob->GetUniqueID(), WorldX, WorldY, WorldZ);
+ NumberOfSuccess++;
+ } // while (retry)
}
diff --git a/src/Chunk.h b/src/Chunk.h
index ededf62cd..90664b513 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -486,8 +486,8 @@ private:
// Pick up a random block of this chunk
- void getRandomBlockCoords(int& a_X, int& a_Y, int& a_Z);
- void getThreeRandomNumber(int& a_X, int& a_Y, int& a_Z,int a_MaxX, int a_MaxY, int a_MaxZ);
+ void GetRandomBlockCoords(int & a_X, int & a_Y, int & a_Z);
+ void GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX, int a_MaxY, int a_MaxZ);
void RemoveBlockEntity(cBlockEntity * a_BlockEntity);
void AddBlockEntity (cBlockEntity * a_BlockEntity);
--
cgit v1.2.3
From 2bd486660ab4140c42da8f0f92304d64afc604e2 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 11 Jul 2014 00:06:05 +0200
Subject: Preparation for player UUID-based storage: LoadFromFile()
---
src/Entities/Player.cpp | 54 ++++++++++++++++++++++++++++++-------------------
src/Entities/Player.h | 9 +++++++++
2 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index dbb8cd26c..2cd4d4b31 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -75,11 +75,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL)
, m_bIsTeleporting(false)
{
- LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
- a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
- this, GetUniqueID()
- );
-
m_InventoryWindow = new cInventoryWindow(*this);
m_CurrentWindow = m_InventoryWindow;
m_InventoryWindow->OpenedByPlayer(*this);
@@ -1690,53 +1685,70 @@ void cPlayer::LoadPermissionsFromDisk()
-bool cPlayer::LoadFromDisk()
+
+bool cPlayer::LoadFromDisk(void)
{
LoadPermissionsFromDisk();
AString SourceFile;
- Printf(SourceFile, "players/%s.json", GetName().c_str() );
+ Printf(SourceFile, "players/%s.json", GetName().c_str());
+
+ bool res = LoadFromFile(SourceFile);
+ if (res)
+ {
+ return true;
+ }
+}
+
+
+
+
+bool cPlayer::LoadFromFile(const AString & a_FileName)
+{
+ // Load the data from the file:
cFile f;
- if (!f.Open(SourceFile, cFile::fmRead))
+ if (!f.Open(a_FileName, cFile::fmRead))
{
// This is a new player whom we haven't seen yet, bail out, let them have the defaults
return false;
}
-
AString buffer;
if (f.ReadRestOfFile(buffer) != f.GetSize())
{
- LOGWARNING("Cannot read player data from file \"%s\"", SourceFile.c_str());
+ LOGWARNING("Cannot read player data from file \"%s\"", a_FileName.c_str());
return false;
}
- f.Close(); //cool kids play nice
+ f.Close();
+ // Parse the JSON format:
Json::Value root;
Json::Reader reader;
if (!reader.parse(buffer, root, false))
{
- LOGWARNING("Cannot parse player data in file \"%s\", player will be reset", SourceFile.c_str());
+ LOGWARNING("Cannot parse player data in file \"%s\"", a_FileName.c_str());
+ return false;
}
+ // Load the player data:
Json::Value & JSON_PlayerPosition = root["position"];
if (JSON_PlayerPosition.size() == 3)
{
- SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble());
- SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble());
- SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble());
+ SetPosX(JSON_PlayerPosition[(unsigned)0].asDouble());
+ SetPosY(JSON_PlayerPosition[(unsigned)1].asDouble());
+ SetPosZ(JSON_PlayerPosition[(unsigned)2].asDouble());
m_LastPos = GetPosition();
}
Json::Value & JSON_PlayerRotation = root["rotation"];
if (JSON_PlayerRotation.size() == 3)
{
- SetYaw ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
- SetPitch ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
- SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
+ SetYaw ((float)JSON_PlayerRotation[(unsigned)0].asDouble());
+ SetPitch ((float)JSON_PlayerRotation[(unsigned)1].asDouble());
+ SetRoll ((float)JSON_PlayerRotation[(unsigned)2].asDouble());
}
- m_Health = root.get("health", 0).asInt();
+ m_Health = root.get("health", 0).asInt();
m_AirLevel = root.get("air", MAX_AIR_LEVEL).asInt();
m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt();
m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
@@ -1763,8 +1775,8 @@ bool cPlayer::LoadFromDisk()
cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
StatSerializer.Load();
- LOGD("Player \"%s\" was read from file, spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
- GetName().c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
+ LOGD("Player \"%s\" was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
+ GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
);
return true;
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index f247ac2f9..7641b0c31 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -41,6 +41,7 @@ public:
cPlayer(cClientHandle * a_Client, const AString & a_PlayerName);
+
virtual ~cPlayer();
virtual void SpawnOn(cClientHandle & a_Client) override;
@@ -337,7 +338,15 @@ public:
bool MoveToWorld(const char * a_WorldName); // tolua_export
bool SaveToDisk(void);
+
+ /** Loads the player data from the disk file.
+ Returns true on success, false on failure. */
bool LoadFromDisk(void);
+
+ /** Loads the player data from the specified file.
+ Returns true on success, false on failure. */
+ bool LoadFromFile(const AString & a_FileName);
+
void LoadPermissionsFromDisk(void); // tolua_export
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
--
cgit v1.2.3
From 6cea81e3833bafbf2916ab2a06edf31c0f9a536e Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 11 Jul 2014 00:06:58 +0200
Subject: Fixed a missing return value.
---
src/Entities/Player.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 2cd4d4b31..5a459d421 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1698,6 +1698,8 @@ bool cPlayer::LoadFromDisk(void)
{
return true;
}
+
+ return false;
}
--
cgit v1.2.3
From df65e8b7bb884fa67307073c0ef7010e3a8792b7 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 11 Jul 2014 12:06:16 +0100
Subject: Improved LinkedPowering speed
* Additionally fixed wires powering other wires through blocks
---
src/Simulator/IncrementalRedstoneSimulator.cpp | 30 +++++++++++++-------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index d96c66c8b..dbadbbb2c 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -1698,8 +1698,8 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl
bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, unsigned char & a_PowerLevel)
{
a_PowerLevel = 0;
- int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
- int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
{
@@ -1716,6 +1716,14 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc
{
continue;
}
+
+ BLOCKTYPE Type = E_BLOCK_AIR;
+ int RelSourceX = itr->a_SourcePos.x - m_Chunk->GetPosX() * cChunkDef::Width;
+ int RelSourceZ = itr->a_SourcePos.z - m_Chunk->GetPosZ() * cChunkDef::Width;
+ if (!m_Chunk->UnboundedRelGetBlockType(RelSourceX, itr->a_SourcePos.y, RelSourceZ, Type) || (Type == E_BLOCK_REDSTONE_WIRE))
+ {
+ continue;
+ }
a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel);
}
@@ -1888,9 +1896,9 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX;
int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ;
- cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ);
- PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList();
- for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list
+ cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values
+ PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position
+ for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr)
{
if (
itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) &&
@@ -1903,7 +1911,8 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
}
}
- for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list
+ // No need to get neighbouring chunk as we can guarantee that when something is powering us, the entry will be in our chunk
+ for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
if (
itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) &&
@@ -1958,15 +1967,6 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered(
int SourceX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelSourceX;
int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ;
- BLOCKTYPE DestBlock = 0;
- if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ, DestBlock))
- {
- return;
- }
- if ((DestBlock == E_BLOCK_REDSTONE_WIRE) && (m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE))
- {
- return;
- }
if (!IsViableMiddleBlock(a_MiddleBlock))
{
return;
--
cgit v1.2.3
From ebea2b7efc1775de66e0c6b6ee66da6f9ad04422 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 11 Jul 2014 13:13:10 +0200
Subject: Player data filenames are based on UUID.
---
src/Entities/Player.cpp | 165 ++++++++++++++++++++++++++++++++----------------
src/Entities/Player.h | 34 ++++++----
src/Server.cpp | 3 +
src/Server.h | 20 ++++++
4 files changed, 155 insertions(+), 67 deletions(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 5a459d421..4e1314209 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -34,46 +34,47 @@
-cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
- : super(etPlayer, 0.6, 1.8)
- , m_bVisible(true)
- , m_FoodLevel(MAX_FOOD_LEVEL)
- , m_FoodSaturationLevel(5.0)
- , m_FoodTickTimer(0)
- , m_FoodExhaustionLevel(0.0)
- , m_FoodPoisonedTicksRemaining(0)
- , m_LastJumpHeight(0)
- , m_LastGroundHeight(0)
- , m_bTouchGround(false)
- , m_Stance(0.0)
- , m_Inventory(*this)
- , m_EnderChestContents(9, 3)
- , m_CurrentWindow(NULL)
- , m_InventoryWindow(NULL)
- , m_Color('-')
- , m_GameMode(eGameMode_NotSet)
- , m_IP("")
- , m_ClientHandle(a_Client)
- , m_NormalMaxSpeed(1.0)
- , m_SprintingMaxSpeed(1.3)
- , m_FlyingMaxSpeed(1.0)
- , m_IsCrouched(false)
- , m_IsSprinting(false)
- , m_IsFlying(false)
- , m_IsSwimming(false)
- , m_IsSubmerged(false)
- , m_IsFishing(false)
- , m_CanFly(false)
- , m_EatingFinishTick(-1)
- , m_LifetimeTotalXp(0)
- , m_CurrentXp(0)
- , m_bDirtyExperience(false)
- , m_IsChargingBow(false)
- , m_BowCharge(0)
- , m_FloaterID(-1)
- , m_Team(NULL)
- , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL)
- , m_bIsTeleporting(false)
+cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
+ super(etPlayer, 0.6, 1.8),
+ m_bVisible(true),
+ m_FoodLevel(MAX_FOOD_LEVEL),
+ m_FoodSaturationLevel(5.0),
+ m_FoodTickTimer(0),
+ m_FoodExhaustionLevel(0.0),
+ m_FoodPoisonedTicksRemaining(0),
+ m_LastJumpHeight(0),
+ m_LastGroundHeight(0),
+ m_bTouchGround(false),
+ m_Stance(0.0),
+ m_Inventory(*this),
+ m_EnderChestContents(9, 3),
+ m_CurrentWindow(NULL),
+ m_InventoryWindow(NULL),
+ m_Color('-'),
+ m_GameMode(eGameMode_NotSet),
+ m_IP(""),
+ m_ClientHandle(a_Client),
+ m_NormalMaxSpeed(1.0),
+ m_SprintingMaxSpeed(1.3),
+ m_FlyingMaxSpeed(1.0),
+ m_IsCrouched(false),
+ m_IsSprinting(false),
+ m_IsFlying(false),
+ m_IsSwimming(false),
+ m_IsSubmerged(false),
+ m_IsFishing(false),
+ m_CanFly(false),
+ m_EatingFinishTick(-1),
+ m_LifetimeTotalXp(0),
+ m_CurrentXp(0),
+ m_bDirtyExperience(false),
+ m_IsChargingBow(false),
+ m_BowCharge(0),
+ m_FloaterID(-1),
+ m_Team(NULL),
+ m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
+ m_bIsTeleporting(false),
+ m_UUID((a_Client != NULL) ? a_Client->GetUUID() : "")
{
m_InventoryWindow = new cInventoryWindow(*this);
m_CurrentWindow = m_InventoryWindow;
@@ -1690,15 +1691,42 @@ bool cPlayer::LoadFromDisk(void)
{
LoadPermissionsFromDisk();
- AString SourceFile;
- Printf(SourceFile, "players/%s.json", GetName().c_str());
-
- bool res = LoadFromFile(SourceFile);
+ // Load from the UUID file:
+ bool res = LoadFromFile(GetUUIDFileName(m_UUID));
if (res)
{
return true;
}
+ // Load from the offline UUID file, if allowed:
+ AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName());
+ if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
+ {
+ res = LoadFromFile(GetUUIDFileName(OfflineUUID));
+ if (res)
+ {
+ return true;
+ }
+ }
+
+ // Load from the old-style name-based file, if allowed:
+ if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData())
+ {
+ AString OldStyleFileName = Printf("players/%s.json", GetName().c_str());
+ res = LoadFromFile(OldStyleFileName);
+ if (res)
+ {
+ // Save in new format and remove the old file
+ SaveToDisk();
+ cFile::Delete(OldStyleFileName);
+ return true;
+ }
+ }
+
+ // None of the files loaded successfully
+ LOGD("Player data file not found for %s (%s, offline %s), will be reset to defaults.",
+ GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str()
+ );
return false;
}
@@ -1791,6 +1819,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName)
bool cPlayer::SaveToDisk()
{
cFile::CreateFolder(FILE_IO_PREFIX + AString("players"));
+ cFile::CreateFolder(FILE_IO_PREFIX + AString("players/") + m_UUID.substr(0, 2));
// create the JSON data
Json::Value JSON_PlayerPosition;
@@ -1822,33 +1851,45 @@ bool cPlayer::SaveToDisk()
root["foodSaturation"] = m_FoodSaturationLevel;
root["foodTickTimer"] = m_FoodTickTimer;
root["foodExhaustion"] = m_FoodExhaustionLevel;
- root["world"] = GetWorld()->GetName();
root["isflying"] = IsFlying();
-
- if (m_GameMode == GetWorld()->GetGameMode())
+ root["lastknownname"] = GetName();
+ if (m_World != NULL)
{
- root["gamemode"] = (int) eGameMode_NotSet;
+ root["world"] = m_World->GetName();
+ if (m_GameMode == m_World->GetGameMode())
+ {
+ root["gamemode"] = (int) eGameMode_NotSet;
+ }
+ else
+ {
+ root["gamemode"] = (int) m_GameMode;
+ }
}
else
{
- root["gamemode"] = (int) m_GameMode;
+ // This happens if the player is saved to new format after loading from the old format
+ root["world"] = m_LoadedWorldName;
+ root["gamemode"] = (int) eGameMode_NotSet;
}
Json::StyledWriter writer;
std::string JsonData = writer.write(root);
- AString SourceFile;
- Printf(SourceFile, "players/%s.json", GetName().c_str() );
+ AString SourceFile = GetUUIDFileName(m_UUID);
cFile f;
if (!f.Open(SourceFile, cFile::fmWrite))
{
- LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", GetName().c_str(), SourceFile.c_str());
+ LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot open file. Player will lose their progress.",
+ GetName().c_str(), SourceFile.c_str()
+ );
return false;
}
if (f.Write(JsonData.c_str(), JsonData.size()) != (int)JsonData.size())
{
- LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str());
+ LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ",
+ GetName().c_str(), SourceFile.c_str()
+ );
return false;
}
@@ -1857,7 +1898,7 @@ bool cPlayer::SaveToDisk()
cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
if (!StatSerializer.Save())
{
- LOGERROR("Could not save stats for player %s", GetName().c_str());
+ LOGWARNING("Could not save stats for player %s", GetName().c_str());
return false;
}
@@ -2170,3 +2211,19 @@ void cPlayer::Detach()
+
+AString cPlayer::GetUUIDFileName(const AString & a_UUID)
+{
+ ASSERT(a_UUID.size() == 36);
+
+ AString res("players/");
+ res.append(a_UUID, 0, 2);
+ res.push_back('/');
+ res.append(a_UUID, 2, AString::npos);
+ res.append(".json");
+ return res;
+}
+
+
+
+
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 7641b0c31..8f9b46e0f 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -528,6 +528,24 @@ protected:
cStatManager m_Stats;
+ /** Flag representing whether the player is currently in a bed
+ Set by a right click on unoccupied bed, unset by a time fast forward or teleport */
+ bool m_bIsInBed;
+
+ /** How long till the player's inventory will be saved
+ Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */
+ unsigned int m_TicksUntilNextSave;
+
+ /** Flag used by food handling system to determine whether a teleport has just happened
+ Will not apply food penalties if found to be true; will set to false after processing
+ */
+ bool m_bIsTeleporting;
+
+ /** The UUID of the player, as read from the ClientHandle.
+ If no ClientHandle is given, the UUID is initialized to empty. */
+ AString m_UUID;
+
+
/** Sets the speed and sends it to the client, so that they are forced to move so. */
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
@@ -554,19 +572,9 @@ protected:
/** Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) */
void ApplyFoodExhaustionFromMovement();
- /** Flag representing whether the player is currently in a bed
- Set by a right click on unoccupied bed, unset by a time fast forward or teleport */
- bool m_bIsInBed;
-
- /** How long till the player's inventory will be saved
- Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */
- unsigned int m_TicksUntilNextSave;
-
- /** Flag used by food handling system to determine whether a teleport has just happened
- Will not apply food penalties if found to be true; will set to false after processing
- */
- bool m_bIsTeleporting;
-
+ /** Returns the filename for the player data based on the UUID given.
+ This can be used both for online and offline UUIDs. */
+ AString GetUUIDFileName(const AString & a_UUID);
} ; // tolua_export
diff --git a/src/Server.cpp b/src/Server.cpp
index 2c695cc70..5d1e51036 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -258,6 +258,9 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
m_ServerID.resize(16, '0');
}
+ m_ShouldLoadOfflinePlayerData = a_SettingsIni.GetValueSetB("PlayerData", "LoadOfflinePlayerData", false);
+ m_ShouldLoadNamedPlayerData = a_SettingsIni.GetValueSetB("PlayerData", "LoadNamedPlayerData", true);
+
m_ClientViewDistance = a_SettingsIni.GetValueSetI("Server", "DefaultViewDistance", cClientHandle::DEFAULT_VIEW_DISTANCE);
if (m_ClientViewDistance < cClientHandle::MIN_VIEW_DISTANCE)
{
diff --git a/src/Server.h b/src/Server.h
index 3d76c8ccf..5227799e8 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -112,8 +112,18 @@ public: // tolua_export
cRsaPrivateKey & GetPrivateKey(void) { return m_PrivateKey; }
const AString & GetPublicKeyDER(void) const { return m_PublicKeyDER; }
+ /** Returns true if authentication has been turned on in server settings. */
bool ShouldAuthenticate(void) const { return m_ShouldAuthenticate; }
+ /** Returns true if offline UUIDs should be used to load data for players whose normal UUIDs cannot be found.
+ Loaded from the settings.ini [PlayerData].LoadOfflinePlayerData setting. */
+ bool ShouldLoadOfflinePlayerData(void) const { return m_ShouldLoadOfflinePlayerData; }
+
+ /** Returns true if old-style playernames should be used to load data for players whose regular datafiles cannot be found.
+ This allows a seamless transition from name-based to UUID-based player storage.
+ Loaded from the settings.ini [PlayerData].LoadNamedPlayerData setting. */
+ bool ShouldLoadNamedPlayerData(void) const { return m_ShouldLoadNamedPlayerData; }
+
private:
friend class cRoot; // so cRoot can create and destroy cServer
@@ -204,6 +214,16 @@ private:
This setting is the same as the "online-mode" setting in Vanilla. */
bool m_ShouldAuthenticate;
+ /** True if offline UUIDs should be used to load data for players whose normal UUIDs cannot be found.
+ This allows transitions from an offline (no-auth) server to an online one.
+ Loaded from the settings.ini [PlayerData].LoadOfflinePlayerData setting. */
+ bool m_ShouldLoadOfflinePlayerData;
+
+ /** True if old-style playernames should be used to load data for players whose regular datafiles cannot be found.
+ This allows a seamless transition from name-based to UUID-based player storage.
+ Loaded from the settings.ini [PlayerData].LoadNamedPlayerData setting. */
+ bool m_ShouldLoadNamedPlayerData;
+
cServer(void);
--
cgit v1.2.3
From 6a33fa84ae03ada5ddeb5861094a4030e612f827 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 11 Jul 2014 12:43:24 +0100
Subject: Suggestions
---
src/BlockEntities/BlockEntity.cpp | 8 ++++----
src/Blocks/BlockHandler.cpp | 11 ++++++-----
src/Simulator/IncrementalRedstoneSimulator.cpp | 5 ++++-
src/WorldStorage/NBTChunkSerializer.cpp | 8 ++++----
4 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index 1deddb0e9..feef088a9 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -27,10 +27,10 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
{
switch (a_BlockType)
{
- case E_BLOCK_TRAPPED_CHEST:
- case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
- case E_BLOCK_LIT_FURNACE:
- case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_CHEST:
+ case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 4ec064d2b..bd48ece52 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -176,7 +176,12 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
{
switch(a_BlockType)
{
- // Block handlers, alphabetically sorted:
+ // Block handlers, alphabetically sorted:
+ case E_BLOCK_CHEST:
+ case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler(a_BlockType);
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler(a_BlockType);
+
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType);
@@ -191,8 +196,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType);
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
- case E_BLOCK_TRAPPED_CHEST:
- case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
@@ -216,7 +219,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
- case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);
case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
@@ -240,7 +242,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType);
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
- case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index dbadbbb2c..141904530 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -68,7 +68,10 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
- a_Chunk->SetIsRedstoneDirty(true); // When the second paramter is present, it means that the first belongs to a neighbouring chunk of the coordinates - alert this chunk for changes
+
+ // If a_OtherChunk is passed (not NULL), it is the chunk that had a block change, and a_Chunk will be the neighbouring chunk of that block
+ // Because said neighbouring chunk does not know of this change but still needs to update its redstone, we set it to dirty
+ a_Chunk->SetIsRedstoneDirty(true);
}
else
{
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 1654153ff..a8d5ee02b 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -817,10 +817,10 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_TRAPPED_CHEST:
- case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_LIT_FURNACE:
- case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
+ case E_BLOCK_CHEST:
+ case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_FURNACE:
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
--
cgit v1.2.3
From ca6bcacdb9216237a25c05b2887ea69c6066356b Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Fri, 11 Jul 2014 17:58:35 +0200
Subject: Changes
---
src/Items/ItemBucket.h | 40 ++++++++++++++++------------------------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index b31266f35..e7214d852 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -41,7 +41,7 @@ public:
bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
{
- if (a_BlockFace > 0)
+ if (a_BlockFace != BLOCK_FACE_NONE)
{
return false;
}
@@ -95,38 +95,18 @@ public:
bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock)
{
- if (a_BlockFace > 0)
+ if (a_BlockFace != BLOCK_FACE_NONE)
{
return false;
}
BLOCKTYPE CurrentBlock;
Vector3i BlockPos;
- if (!GetPlaceableBlockFromTrace(a_World, a_Player, BlockPos, CurrentBlock))
+ if (!GetPlacementCoordsFromTrace(a_World, a_Player, BlockPos, CurrentBlock))
{
return false;
}
- bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
- if (!CanWashAway)
- {
- // The block pointed at cannot be washed away, so put fluid on top of it / on its sides
- // AddFaceDirection(BlockPos.x, BlockPos.y, BlockPos.z, a_BlockFace);
- // CurrentBlock = a_World->GetBlock(BlockPos);
- }
- if (
- !CanWashAway &&
- (CurrentBlock != E_BLOCK_AIR) &&
- (CurrentBlock != E_BLOCK_WATER) &&
- (CurrentBlock != E_BLOCK_STATIONARY_WATER) &&
- (CurrentBlock != E_BLOCK_LAVA) &&
- (CurrentBlock != E_BLOCK_STATIONARY_LAVA)
- )
- {
- // Cannot place water here
- return false;
- }
-
if (a_Player->GetGameMode() != gmCreative)
{
// Remove fluid bucket, add empty bucket:
@@ -144,6 +124,7 @@ public:
}
// Wash away anything that was there prior to placing:
+ bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
if (CanWashAway)
{
cBlockHandler * Handler = BlockHandler(CurrentBlock);
@@ -209,7 +190,7 @@ public:
}
- bool GetPlaceableBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
+ bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
{
class cCallbacks :
public cBlockTracer::cCallbacks
@@ -229,6 +210,17 @@ public:
{
if (a_BlockType != E_BLOCK_AIR)
{
+ bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock);
+ if (
+ !CanWashAway &&
+ (m_LastBlock != E_BLOCK_AIR) &&
+ !IsBlockWater(m_LastBlock) &&
+ !IsBlockLava(m_LastBlock)
+ )
+ {
+ return true;
+ }
+
m_HasHitLastBlock = true;
return true;
}
--
cgit v1.2.3
From 416c160fb52b400e81e029a358c503053a2b93ec Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Fri, 11 Jul 2014 19:40:33 +0100
Subject: Suggestions
---
src/Blocks/BlockHandler.cpp | 3 ++-
src/Blocks/BlockPiston.h | 2 +-
src/Simulator/IncrementalRedstoneSimulator.cpp | 3 +++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index bd48ece52..fcd5e2b41 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -176,12 +176,13 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
{
switch(a_BlockType)
{
- // Block handlers, alphabetically sorted:
+ // Duplicate block handlers (two blocks use one handler), alphabetically sorted:
case E_BLOCK_CHEST:
case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler(a_BlockType);
case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler(a_BlockType);
+ // Block handlers, alphabetically sorted:
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType);
case E_BLOCK_ANVIL: return new cBlockAnvilHandler (a_BlockType);
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index 3913da320..27a44d829 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -104,7 +104,7 @@ private:
case E_BLOCK_ENCHANTMENT_TABLE:
case E_BLOCK_END_PORTAL:
case E_BLOCK_END_PORTAL_FRAME:
- // Ender chests can totally be pushed/pulled in MCS :)
+ // Notice the lack of an E_BLOCK_ENDER_CHEST here; its because ender chests can totally be pushed/pulled in MCS :)
case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_HOPPER:
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 141904530..ffaa02ef9 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -1915,6 +1915,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
}
// No need to get neighbouring chunk as we can guarantee that when something is powering us, the entry will be in our chunk
+ // TODO: on C++11 support, change this to a llama function pased to a std::remove_if
for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
if (
@@ -2077,6 +2078,8 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in
void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall)
{
+ // TODO: on C++11 support, change both of these to llama functions pased to a std::remove_if
+
for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();)
{
if (itr->a_SourcePos.Equals(Vector3i(a_SourceX, a_SourceY, a_SourceZ)))
--
cgit v1.2.3
From f73042fb02ead13aa870f061a08f56d84ed1dc99 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Fri, 11 Jul 2014 23:12:57 +0200
Subject: Simplified the player data loading.
---
src/Entities/Player.cpp | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 4e1314209..944ed643e 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1692,8 +1692,7 @@ bool cPlayer::LoadFromDisk(void)
LoadPermissionsFromDisk();
// Load from the UUID file:
- bool res = LoadFromFile(GetUUIDFileName(m_UUID));
- if (res)
+ if (LoadFromFile(GetUUIDFileName(m_UUID)))
{
return true;
}
@@ -1702,8 +1701,7 @@ bool cPlayer::LoadFromDisk(void)
AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName());
if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
{
- res = LoadFromFile(GetUUIDFileName(OfflineUUID));
- if (res)
+ if (LoadFromFile(GetUUIDFileName(OfflineUUID)))
{
return true;
}
@@ -1713,18 +1711,19 @@ bool cPlayer::LoadFromDisk(void)
if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData())
{
AString OldStyleFileName = Printf("players/%s.json", GetName().c_str());
- res = LoadFromFile(OldStyleFileName);
- if (res)
+ if (LoadFromFile(OldStyleFileName))
{
// Save in new format and remove the old file
- SaveToDisk();
- cFile::Delete(OldStyleFileName);
+ if (SaveToDisk())
+ {
+ cFile::Delete(OldStyleFileName);
+ }
return true;
}
}
// None of the files loaded successfully
- LOGD("Player data file not found for %s (%s, offline %s), will be reset to defaults.",
+ LOG("Player data file not found for %s (%s, offline %s), will be reset to defaults.",
GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str()
);
return false;
--
cgit v1.2.3
From 4e6395d6ff9f34edb4dd36dc1f8e845c56b499f4 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 11 Jul 2014 17:27:29 -0700
Subject: For now, removed creator member from Entity Effect for pointer safety
---
src/Bindings/Plugin.h | 2 +-
src/Bindings/PluginLua.cpp | 4 +-
src/Bindings/PluginLua.h | 2 +-
src/Bindings/PluginManager.cpp | 4 +-
src/Bindings/PluginManager.h | 2 +-
src/Entities/EntityEffect.cpp | 62 +++++++++++----------
src/Entities/EntityEffect.h | 104 +++++++++++++++++-------------------
src/Entities/Pawn.cpp | 7 +--
src/Entities/Pawn.h | 3 +-
src/Entities/SplashPotionEntity.cpp | 2 +-
src/Items/ItemPotion.h | 4 +-
src/Mobs/CaveSpider.cpp | 2 +-
12 files changed, 94 insertions(+), 104 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index dabe8debb..5196a03dc 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -57,7 +57,7 @@ public:
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
- virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) = 0;
+ virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index e10cca708..a08803189 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -420,14 +420,14 @@ bool cPluginLua::OnDisconnect(cClientHandle & a_Client, const AString & a_Reason
-bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier)
+bool cPluginLua::OnEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_ENTITY_ADD_EFFECT];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier, cLuaState::Return, res);
if (res)
{
return true;
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 94371c830..0ea76ba24 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -80,7 +80,7 @@ public:
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
- virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier) override;
+ virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index c80344c30..2264faf8b 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -474,7 +474,7 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
-bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier)
+bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_ENTITY_ADD_EFFECT);
if (Plugins == m_Hooks.end())
@@ -483,7 +483,7 @@ bool cPluginManager::CallHookEntityAddEffect(cEntity & a_Entity, int a_EffectTyp
}
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_Originator, a_DistanceModifier))
+ if ((*itr)->OnEntityAddEffect(a_Entity, a_EffectType, a_EffectDurationTicks, a_EffectIntensity, a_DistanceModifier))
{
return true;
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 4d5a350d4..2f0ec0e27 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -184,7 +184,7 @@ public: // tolua_export
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
- bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, cEntity * a_Originator, double a_DistanceModifier);
+ bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 9881785cb..e68ded8b0 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -11,7 +11,6 @@ cEntityEffect::cEntityEffect():
m_Ticks(0),
m_Duration(0),
m_Intensity(0),
- m_Creator(NULL),
m_DistanceModifier(1)
{
@@ -21,11 +20,10 @@ cEntityEffect::cEntityEffect():
-cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, cPawn *a_Creator, double a_DistanceModifier):
+cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier):
m_Ticks(0),
m_Duration(a_Duration),
m_Intensity(a_Intensity),
- m_Creator(a_Creator),
m_DistanceModifier(a_DistanceModifier)
{
@@ -44,35 +42,35 @@ cEntityEffect::~cEntityEffect()
-cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier)
+cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
{
switch (a_EffectType)
{
- case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effNoEffect: return new cEntityEffect (a_Duration, a_Intensity, a_DistanceModifier);
- case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
- case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ case cEntityEffect::effAbsorption: return new cEntityEffectAbsorption (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effBlindness: return new cEntityEffectBlindness (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effFireResistance: return new cEntityEffectFireResistance(a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effHaste: return new cEntityEffectHaste (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effHealthBoost: return new cEntityEffectHealthBoost (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effHunger: return new cEntityEffectHunger (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effInstantDamage: return new cEntityEffectInstantDamage (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effInstantHealth: return new cEntityEffectInstantHealth (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effInvisibility: return new cEntityEffectInvisibility (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effJumpBoost: return new cEntityEffectJumpBoost (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effMiningFatigue: return new cEntityEffectMiningFatigue (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effNausea: return new cEntityEffectNausea (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effNightVision: return new cEntityEffectNightVision (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effPoison: return new cEntityEffectPoison (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effRegeneration: return new cEntityEffectRegeneration (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effResistance: return new cEntityEffectResistance (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effSaturation: return new cEntityEffectSaturation (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effSlowness: return new cEntityEffectSlowness (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effSpeed: return new cEntityEffectSpeed (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effStrength: return new cEntityEffectStrength (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effWaterBreathing: return new cEntityEffectWaterBreathing(a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effWeakness: return new cEntityEffectWeakness (a_Duration, a_Intensity, a_DistanceModifier);
+ case cEntityEffect::effWither: return new cEntityEffectWither (a_Duration, a_Intensity, a_DistanceModifier);
}
ASSERT(!"Unhandled entity effect type!");
@@ -120,7 +118,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
{
if (((cMonster &) a_Target).IsUndead())
{
- a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0);
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
return;
}
}
@@ -147,7 +145,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
return;
}
}
- a_Target.TakeDamage(dtPotionOfHarming, m_Creator, amount, 0);
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
}
@@ -248,7 +246,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
// Cannot take poison damage when health is at 1
if (a_Target.GetHealth() > 1)
{
- a_Target.TakeDamage(dtPoisoning, m_Creator, 1, 0);
+ a_Target.TakeDamage(dtPoisoning, NULL, 1, 0);
}
}
}
@@ -269,7 +267,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
if (m_Ticks % frequency == 0)
{
- a_Target.TakeDamage(dtWither, m_Creator, 1, 0);
+ a_Target.TakeDamage(dtWither, NULL, 1, 0);
}
//TODO: " withered away>
}
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index ae7958e11..c593fba81 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -42,9 +42,8 @@ public:
/** Creates an entity effect of the specified type
@param a_Duration How long this effect will last, in ticks
@param a_Intensity How strong the effect will be applied
- @param a_Creator The pawn that produced this entity effect
@param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
- cEntityEffect(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1);
+ cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1);
virtual ~cEntityEffect(void);
@@ -53,9 +52,8 @@ public:
@param a_EffectType The effect type to create the effect from
@param a_Duration How long this effect will last, in ticks
@param a_Intensity How strong the effect will be applied
- @param a_Creator The pawn that produced this entity effect
@param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
- static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier);
+ static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier);
/** Returns how many ticks this effect has been active for */
int GetTicks() { return m_Ticks; }
@@ -63,15 +61,12 @@ public:
int GetDuration() { return m_Duration; }
/** Returns how strong the effect will be applied */
short GetIntensity() { return m_Intensity; }
- /** Returns the pawn that produced this entity effect */
- cPawn *GetCreator() { return m_Creator; }
/** Returns the distance modifier for affecting potency */
double GetDistanceModifier() { return m_DistanceModifier; }
void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; }
void SetDuration(int a_Duration) { m_Duration = a_Duration; }
void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
- void SetCreator(cPawn * a_Creator) { m_Creator = a_Creator; }
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
virtual void OnTick(cPawn & a_Target);
@@ -88,9 +83,6 @@ protected:
/** How strong the effect will be applied */
short m_Intensity;
- /** The pawn that produced this entity effect (threw the potion, etc) */
- cPawn *m_Creator;
-
/** The distance modifier for affecting potency */
double m_DistanceModifier;
};
@@ -103,8 +95,8 @@ class cEntityEffectSpeed:
{
typedef cEntityEffect super;
public:
- cEntityEffectSpeed(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectSpeed(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -117,8 +109,8 @@ class cEntityEffectSlowness:
{
typedef cEntityEffect super;
public:
- cEntityEffectSlowness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectSlowness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -131,8 +123,8 @@ class cEntityEffectHaste:
{
typedef cEntityEffect super;
public:
- cEntityEffectHaste(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectHaste(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -145,8 +137,8 @@ class cEntityEffectMiningFatigue:
{
typedef cEntityEffect super;
public:
- cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectMiningFatigue(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -159,8 +151,8 @@ class cEntityEffectStrength:
{
typedef cEntityEffect super;
public:
- cEntityEffectStrength(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectStrength(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -173,8 +165,8 @@ class cEntityEffectInstantHealth:
{
typedef cEntityEffect super;
public:
- cEntityEffectInstantHealth(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectInstantHealth(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -189,8 +181,8 @@ class cEntityEffectInstantDamage:
{
typedef cEntityEffect super;
public:
- cEntityEffectInstantDamage(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectInstantDamage(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -205,8 +197,8 @@ class cEntityEffectJumpBoost:
{
typedef cEntityEffect super;
public:
- cEntityEffectJumpBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectJumpBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -219,8 +211,8 @@ class cEntityEffectNausea:
{
typedef cEntityEffect super;
public:
- cEntityEffectNausea(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -233,8 +225,8 @@ class cEntityEffectRegeneration:
{
typedef cEntityEffect super;
public:
- cEntityEffectRegeneration(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectRegeneration(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -249,8 +241,8 @@ class cEntityEffectResistance:
{
typedef cEntityEffect super;
public:
- cEntityEffectResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -263,8 +255,8 @@ class cEntityEffectFireResistance:
{
typedef cEntityEffect super;
public:
- cEntityEffectFireResistance(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectFireResistance(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -277,8 +269,8 @@ class cEntityEffectWaterBreathing:
{
typedef cEntityEffect super;
public:
- cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectWaterBreathing(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -291,8 +283,8 @@ class cEntityEffectInvisibility:
{
typedef cEntityEffect super;
public:
- cEntityEffectInvisibility(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectInvisibility(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -305,8 +297,8 @@ class cEntityEffectBlindness:
{
typedef cEntityEffect super;
public:
- cEntityEffectBlindness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectBlindness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -319,8 +311,8 @@ class cEntityEffectNightVision:
{
typedef cEntityEffect super;
public:
- cEntityEffectNightVision(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectNightVision(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -333,8 +325,8 @@ class cEntityEffectHunger:
{
typedef cEntityEffect super;
public:
- cEntityEffectHunger(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectHunger(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -349,8 +341,8 @@ class cEntityEffectWeakness:
{
typedef cEntityEffect super;
public:
- cEntityEffectWeakness(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectWeakness(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -365,8 +357,8 @@ class cEntityEffectPoison:
{
typedef cEntityEffect super;
public:
- cEntityEffectPoison(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectPoison(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -381,8 +373,8 @@ class cEntityEffectWither:
{
typedef cEntityEffect super;
public:
- cEntityEffectWither(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectWither(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
@@ -397,8 +389,8 @@ class cEntityEffectHealthBoost:
{
typedef cEntityEffect super;
public:
- cEntityEffectHealthBoost(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectHealthBoost(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -411,8 +403,8 @@ class cEntityEffectAbsorption:
{
typedef cEntityEffect super;
public:
- cEntityEffectAbsorption(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectAbsorption(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
@@ -425,8 +417,8 @@ class cEntityEffectSaturation:
{
typedef cEntityEffect super;
public:
- cEntityEffectSaturation(int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_Creator, a_DistanceModifier)
+ cEntityEffectSaturation(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 62f71e20f..840736f6a 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -52,16 +52,17 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
void cPawn::KilledBy(cEntity * a_Killer)
{
ClearEntityEffects();
+ super::KilledBy(a_Killer);
}
-void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, cPawn * a_Creator, double a_DistanceModifier)
+void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
{
// Check if the plugins allow the addition:
- if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier))
+ if (cPluginManager::Get()->CallHookEntityAddEffect(*this, a_EffectType, a_Duration, a_Intensity, a_DistanceModifier))
{
// A plugin disallows the addition, bail out.
return;
@@ -74,7 +75,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, s
}
a_Duration = (int)(a_Duration * a_DistanceModifier);
- m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_Creator, a_DistanceModifier);
+ m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_DistanceModifier);
m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, a_Duration);
m_EntityEffects[a_EffectType]->OnActivate(*this);
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 307e5db3d..252ec5edb 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -30,10 +30,9 @@ public:
@param a_EffectType The entity effect to apply
@param a_EffectDurationTicks The duration of the effect
@param a_EffectIntensity The level of the effect (0 = Potion I, 1 = Potion II, etc)
- @param a_Creator The pawn that produced the effect (e.g. threw the potion)
@param a_DistanceModifier The scalar multiplied to the potion duration, only applies to splash potions)
*/
- void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, cPawn * a_Creator, double a_DistanceModifier = 1);
+ void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
/** Removes a currently applied entity effect
@param a_EffectType The entity effect to remove
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 3d2ef279f..e84f1c430 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -79,7 +79,7 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
}
m_EntityEffect.SetDistanceModifier(Reduction);
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), m_EntityEffect.GetCreator(), Reduction);
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
}
return false;
}
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 43b9f280d..5badeda94 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -123,7 +123,7 @@ public:
Vector3d Speed = a_Player->GetLookVector() * 7;
short potion_damage = a_Item.m_ItemDamage;
- cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage), a_Player), GetPotionName(potion_damage));
+ cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage)), GetPotionName(potion_damage));
if (Projectile == NULL)
{
return false;
@@ -146,7 +146,7 @@ public:
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
// Called when potion is a drinkable potion
- a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage), a_Player);
+ a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage));
a_Player->GetInventory().RemoveOneEquippedItem();
a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
return true;
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 34135714d..118a6e93b 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -34,7 +34,7 @@ void cCaveSpider::Attack(float a_Dt)
if (m_Target->IsPawn())
{
// TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
- ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0, this);
+ ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
}
}
--
cgit v1.2.3
From 8cbd43e0434323dcb1ccba6e1b95a3ca16d35d44 Mon Sep 17 00:00:00 2001
From: archshift
Date: Fri, 11 Jul 2014 18:58:11 -0700
Subject: Added splash potions to NBT serialization and retrieval
---
src/Entities/ProjectileEntity.cpp | 2 +-
src/Entities/SplashPotionEntity.h | 8 ++++++++
src/WorldStorage/NBTChunkSerializer.cpp | 11 +++++++++++
src/WorldStorage/NBTChunkSerializer.h | 1 +
src/WorldStorage/WSSAnvil.cpp | 28 ++++++++++++++++++++++++++++
src/WorldStorage/WSSAnvil.h | 1 +
6 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index c2d97589f..9c1161ac3 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -312,7 +312,7 @@ AString cProjectileEntity::GetMCAClassName(void) const
case pkFireCharge: return "SmallFireball";
case pkEnderPearl: return "ThrownEnderpearl";
case pkExpBottle: return "ThrownExpBottle";
- case pkSplashPotion: return "ThrownPotion";
+ case pkSplashPotion: return "SplashPotion";
case pkWitherSkull: return "WitherSkull";
case pkFirework: return "Firework";
case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this?
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 548ba3a3e..ad656d8ab 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -27,6 +27,14 @@ public:
cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName);
+ cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; }
+ cEntityEffect GetEntityEffect() { return m_EntityEffect; }
+ int GetPotionName() { return m_PotionName; }
+
+ void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
+ void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
+ void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; }
+
protected:
// cProjectileEntity overrides:
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 317ace795..fe65fa723 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -29,6 +29,7 @@
#include "../Entities/Minecart.h"
#include "../Entities/Pickup.h"
#include "../Entities/ArrowEntity.h"
+#include "../Entities/SplashPotionEntity.h"
#include "../Entities/TNTEntity.h"
#include "../Entities/ExpOrb.h"
#include "../Entities/HangingEntity.h"
@@ -604,6 +605,16 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.AddDouble("damage", Arrow->GetDamageCoeff());
break;
}
+ case cProjectileEntity::pkSplashPotion:
+ {
+ cSplashPotionEntity * Potion = (cSplashPotionEntity *)a_Projectile;
+
+ m_Writer.AddInt("EffectType", (Int16)Potion->GetEntityEffectType());
+ m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
+ m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
+ m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
+ m_Writer.AddInt("PotionName", Potion->GetPotionName());
+ }
case cProjectileEntity::pkGhastFireball:
{
m_Writer.AddInt("ExplosionPower", 1);
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index 112afc27e..9c87c11ca 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -46,6 +46,7 @@ class cTNTEntity;
class cExpOrb;
class cHangingEntity;
class cItemFrame;
+class cEntityEffect;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index f13c4d4d2..3fac01614 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -36,6 +36,7 @@
#include "../Entities/Minecart.h"
#include "../Entities/Pickup.h"
#include "../Entities/ArrowEntity.h"
+#include "../Entities/SplashPotionEntity.h"
#include "../Entities/ThrownEggEntity.h"
#include "../Entities/ThrownEnderPearlEntity.h"
#include "../Entities/ThrownSnowballEntity.h"
@@ -1152,6 +1153,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
LoadArrowFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
+ else if (strncmp(a_IDTag, "SplashPotion", a_IDTagLength) == 0)
+ {
+ LoadSplashPotionFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
+ }
else if (strncmp(a_IDTag, "Snowball", a_IDTagLength) == 0)
{
LoadSnowballFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
@@ -1658,6 +1663,29 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
+void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ std::auto_ptr SplashPotion(new cSplashPotionEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0), cEntityEffect::effNoEffect, cEntityEffect(), 0));
+ if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx))
+ {
+ return;
+ }
+
+ int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration");
+ int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
+ int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier");
+
+ SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
+ SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
+ SplashPotion->SetPotionName(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
+
+ // Store the new splash potion in the entities list:
+ a_Entities.push_back(SplashPotion.release());
+}
+
+
+
+
void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 7542a828a..545b00509 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -163,6 +163,7 @@ protected:
void LoadMinecartHFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadArrowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSplashPotionFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSnowballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadEggFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFireballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
--
cgit v1.2.3
From 68668d7a6eb3a989fc331f68fb660fff19b2f069 Mon Sep 17 00:00:00 2001
From: daniel0916
Date: Sat, 12 Jul 2014 12:44:59 +0200
Subject: Changes
---
src/Items/ItemBucket.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index e7214d852..b3f008229 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -124,8 +124,7 @@ public:
}
// Wash away anything that was there prior to placing:
- bool CanWashAway = cFluidSimulator::CanWashAway(CurrentBlock);
- if (CanWashAway)
+ if (cFluidSimulator::CanWashAway(CurrentBlock))
{
cBlockHandler * Handler = BlockHandler(CurrentBlock);
if (Handler->DoesDropOnUnsuitable())
@@ -188,9 +187,9 @@ public:
a_BlockPos = Callbacks.m_Pos;
return true;
}
-
-
- bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
+
+
+ bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType)
{
class cCallbacks :
public cBlockTracer::cCallbacks
--
cgit v1.2.3
From e71e432633a26d0ab24d2da7e3707e4ab7060296 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 12 Jul 2014 22:06:25 +0100
Subject: Suggestions and bug fix
* Fixed hoppers pushing/pulling to/from (trapped)chests that do not form
a double-chest with the chest type directly connected to said hopper;
thank you, @madmaxoft
---
src/BlockEntities/BlockEntity.cpp | 11 +++++------
src/BlockEntities/HopperEntity.cpp | 17 +++++++++++++----
src/Blocks/BlockHandler.cpp | 12 +++++-------
src/Chunk.cpp | 2 +-
src/Simulator/IncrementalRedstoneSimulator.cpp | 2 +-
src/UI/Window.cpp | 2 +-
src/WorldStorage/NBTChunkSerializer.cpp | 19 +++++++++----------
7 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index feef088a9..2910c735e 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -27,21 +27,20 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
{
switch (a_BlockType)
{
- case E_BLOCK_CHEST:
- case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
- case E_BLOCK_FURNACE:
- case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
-
case E_BLOCK_BEACON: return new cBeaconEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DISPENSER: return new cDispenserEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
}
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index bcaf26701..181b6a2ce 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -380,7 +380,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
return true;
}
- // Check if the chest is a double-chest, if so, try to move from there:
+ // Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there:
static const struct
{
int x, z;
@@ -403,7 +403,11 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
}
BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z);
- if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST))
+ if (
+ ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) ||
+ ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) ||
+ ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST))
+ )
{
continue;
}
@@ -556,10 +560,11 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
}
if (MoveItemsToGrid(*Chest))
{
+ // Chest block directly connected was not full
return true;
}
- // Check if the chest is a double-chest, if so, try to move into the other half:
+ // Check if the chest is a double-chest (chest block directly connected was full), if so, try to move into the other half:
static const struct
{
int x, z;
@@ -584,7 +589,11 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
}
BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z);
- if ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST))
+ if (
+ ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) ||
+ ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) ||
+ ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST))
+ )
{
continue;
}
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index fcd5e2b41..730774ab1 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -176,12 +176,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
{
switch(a_BlockType)
{
- // Duplicate block handlers (two blocks use one handler), alphabetically sorted:
- case E_BLOCK_CHEST:
- case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler(a_BlockType);
- case E_BLOCK_FURNACE:
- case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler(a_BlockType);
-
// Block handlers, alphabetically sorted:
case E_BLOCK_ACACIA_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_ACTIVATOR_RAIL: return new cBlockRailHandler (a_BlockType);
@@ -197,6 +191,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType);
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
+ case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType);
case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
@@ -220,6 +215,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
+ case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);
case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
@@ -242,8 +238,9 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType);
case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType);
- case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler(a_BlockType);
+ case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType);
+ case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType);
case E_BLOCK_MELON_STEM: return new cBlockStemsHandler (a_BlockType);
@@ -296,6 +293,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_TORCH: return new cBlockTorchHandler (a_BlockType);
case E_BLOCK_TRAPDOOR: return new cBlockTrapdoorHandler (a_BlockType);
case E_BLOCK_TNT: return new cBlockTNTHandler (a_BlockType);
+ case E_BLOCK_TRAPPED_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index c1f9dbfd6..3c63a2dc9 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -2123,7 +2123,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
{
continue;
}
- if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST) /* Trapped chests use normal chests' handlers */)
+ if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers
{
// There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out
return false;
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index ffaa02ef9..3c037b6db 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -1918,7 +1918,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
// TODO: on C++11 support, change this to a llama function pased to a std::remove_if
for (PoweredBlocksList::iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
- if (
+ if (
itr->a_BlockPos.Equals(Vector3i(SourceX, a_RelSourceY, SourceZ)) &&
itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)) &&
(m_Chunk->GetBlock(a_RelSourceX, a_RelSourceY, a_RelSourceZ) == E_BLOCK_REDSTONE_WIRE)
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 56e1d00e4..37d3c6bd6 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -1010,7 +1010,7 @@ bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
cChestWindow::~cChestWindow()
{
// Send out the chest-close packet:
- m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST /* Client apparently doesn't mind if we give this to trapped chests as well */);
+ m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
}
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index a8d5ee02b..abe55156b 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -817,22 +817,21 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_CHEST:
- case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_FURNACE:
- case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
-
+ case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break;
case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break;
case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
- case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
- case E_BLOCK_SIGN_POST:
- case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
+ case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity( (cJukeboxEntity *) a_Entity); break;
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
- case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *) a_Entity); break;
+ case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
default:
{
--
cgit v1.2.3
From 9ab0f259c763d72f6af2560007d4f5cd7b5694cd Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 12 Jul 2014 23:25:59 +0200
Subject: Fixed alignment.
---
src/BlockEntities/BlockEntity.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/BlockEntities/BlockEntity.cpp b/src/BlockEntities/BlockEntity.cpp
index 2910c735e..05ad03a3d 100644
--- a/src/BlockEntities/BlockEntity.cpp
+++ b/src/BlockEntities/BlockEntity.cpp
@@ -34,11 +34,11 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_ENDER_CHEST: return new cEnderChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_FLOWER_POT: return new cFlowerPotEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_HEAD: return new cMobHeadEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
- case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
case E_BLOCK_TRAPPED_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World, a_BlockType);
case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
@@ -47,6 +47,7 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
);
+ ASSERT(!"Requesting creation of an unknown block entity");
return NULL;
}
--
cgit v1.2.3
From c4f1284d9cca12f77184b7a0b9521e87f6533974 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 12 Jul 2014 23:30:34 +0200
Subject: cChestEntity: Renamed a member to avoid confusion.
---
src/BlockEntities/ChestEntity.cpp | 2 +-
src/BlockEntities/ChestEntity.h | 15 ++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index 8626f3cad..ca164464c 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -13,7 +13,7 @@
cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type) :
super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
- m_ActivePlayers(0)
+ m_NumActivePlayers(0)
{
cBlockEntityWindowOwner::SetBlockEntity(this);
}
diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h
index 42cf7657c..310618504 100644
--- a/src/BlockEntities/ChestEntity.h
+++ b/src/BlockEntities/ChestEntity.h
@@ -34,7 +34,7 @@ public:
// tolua_end
- /// Constructor used for normal operation
+ /** Constructor used for normal operation */
cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
virtual ~cChestEntity();
@@ -48,19 +48,20 @@ public:
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
- /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate.
+ /** Opens a new chest window for this chest.
+ Scans for neighbors to open a double chest window, if appropriate. */
void OpenNewWindow(void);
/** Gets the number of players who currently have this chest open */
- int GetNumberOfPlayers(void) const { return m_ActivePlayers; }
+ int GetNumberOfPlayers(void) const { return m_NumActivePlayers; }
- /** Gets the number of players who currently have this chest open */
- void SetNumberOfPlayers(int a_Amount) { m_ActivePlayers = a_Amount; }
+ /** Sets the number of players who currently have this chest open */
+ void SetNumberOfPlayers(int a_NumActivePlayers) { m_NumActivePlayers = a_NumActivePlayers; }
private:
- /** Holds the number of players who currently have this chest open */
- int m_ActivePlayers;
+ /** Number of players who currently have this chest open */
+ int m_NumActivePlayers;
} ; // tolua_export
--
cgit v1.2.3
From d72a81cb8e135695b947bea4bac320e21c9af278 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 12 Jul 2014 23:34:32 +0200
Subject: cHopperEntity: Simplified chest conditions.
---
src/BlockEntities/HopperEntity.cpp | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 181b6a2ce..aaf82d150 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -403,12 +403,9 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
}
BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z);
- if (
- ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) ||
- ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) ||
- ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST))
- )
+ if (Block != Chest->GetBlockType())
{
+ // Not the same kind of chest
continue;
}
@@ -589,12 +586,9 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
}
BLOCKTYPE Block = Neighbor->GetBlock(x, a_BlockY, z);
- if (
- ((Block != E_BLOCK_CHEST) && (Block != E_BLOCK_TRAPPED_CHEST)) ||
- ((Block == E_BLOCK_CHEST) && (Chest->GetBlockType() != E_BLOCK_CHEST)) ||
- ((Block == E_BLOCK_TRAPPED_CHEST) && (Chest->GetBlockType() != E_BLOCK_TRAPPED_CHEST))
- )
+ if (Block != Chest->GetBlockType())
{
+ // Not the same kind of chest
continue;
}
--
cgit v1.2.3
From e2e0f52ecb8683a385066c2cc11d8544d8f93c60 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sat, 12 Jul 2014 23:48:39 +0200
Subject: cNBTChunkSerializer: Fixed alignment.
---
src/WorldStorage/NBTChunkSerializer.cpp | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index abe55156b..f5ce06fcb 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -817,21 +817,21 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break;
- case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
- case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
- case E_BLOCK_ENDER_CHEST: /* No need to be saved */ break;
- case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
- case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
- case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity( (cJukeboxEntity *) a_Entity); break;
- case E_BLOCK_LIT_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
- case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
- case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break;
- case E_BLOCK_TRAPPED_CHEST: AddChestEntity((cChestEntity *)a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
+ case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
+ case E_BLOCK_ENDER_CHEST: /* No data to be saved */ break;
+ case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
+ case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
+ case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
+ case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
+ case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_TRAPPED_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
+ case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
default:
{
--
cgit v1.2.3
From 9f4348fb09ae77aebcf0cdcfc2139613756dbcdc Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 12 Jul 2014 22:50:28 +0100
Subject: Simplified buckets code slightly
---
src/Items/ItemBucket.h | 47 +++++++++++++++--------------------------------
1 file changed, 15 insertions(+), 32 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index b3f008229..20d955de4 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -196,54 +196,37 @@ public:
{
public:
Vector3i m_Pos;
- bool m_HasHitLastBlock;
- BLOCKTYPE m_LastBlock;
-
-
- cCallbacks(void) :
- m_HasHitLastBlock(false)
- {
- }
+ BLOCKTYPE m_ReplacedBlock;
virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override
{
if (a_BlockType != E_BLOCK_AIR)
{
- bool CanWashAway = cFluidSimulator::CanWashAway(m_LastBlock);
- if (
- !CanWashAway &&
- (m_LastBlock != E_BLOCK_AIR) &&
- !IsBlockWater(m_LastBlock) &&
- !IsBlockLava(m_LastBlock)
- )
+ m_ReplacedBlock = a_BlockType;
+ if (!cFluidSimulator::CanWashAway(a_BlockType))
{
- return true;
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it!
}
-
- m_HasHitLastBlock = true;
- return true;
- }
-
- m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ);
- m_LastBlock = a_BlockType;
-
+ m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it)
+ return true; // Abort tracing
+ }
return false;
}
} Callbacks;
cLineBlockTracer Tracer(*a_World, Callbacks);
Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector());
- Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
-
- Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z);
+ Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
- if (!Callbacks.m_HasHitLastBlock)
+ // cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed
+ // Use this to judge whether the position is valid
+ if (!Tracer.Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z))
{
- return false;
+ a_BlockPos = Callbacks.m_Pos;
+ a_BlockType = Callbacks.m_ReplacedBlock;
+ return true;
}
- a_BlockPos = Callbacks.m_Pos;
- a_BlockType = Callbacks.m_LastBlock;
- return true;
+ return false;
}
};
--
cgit v1.2.3
From 945dfe75d753271394ef4109b66b1a526e5b2c93 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sat, 12 Jul 2014 22:52:45 +0100
Subject: Comment grammar correction
---
src/Items/ItemBucket.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 20d955de4..5529b4e36 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -205,7 +205,7 @@ public:
m_ReplacedBlock = a_BlockType;
if (!cFluidSimulator::CanWashAway(a_BlockType))
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was a unwashawayable block, can't overwrite it!
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was an unwashawayable block, can't overwrite it!
}
m_Pos.Set(a_BlockX, a_BlockY, a_BlockZ); // (Block could be washed away, replace it)
return true; // Abort tracing
--
cgit v1.2.3
From 905fed09a64667f6f9cebf353dc65e6f094fbc72 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 13 Jul 2014 00:51:42 +0200
Subject: Fixed wrong types. (BLOCKTYPE -> NIBBLETYPE)
---
src/BlockArea.cpp | 2 +-
src/ChunkMap.cpp | 4 ++--
src/ChunkMap.h | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 185582ba3..0e4c42f0f 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -59,7 +59,7 @@ void InternalMergeBlocks(
}
else
{
- BLOCKTYPE FakeDestMeta = 0;
+ NIBBLETYPE FakeDestMeta = 0;
Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], FakeDestMeta, (NIBBLETYPE)0);
}
++DstIdx;
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 35d55d396..4040fff9f 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1278,7 +1278,7 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP
-void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients)
+void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients)
{
cChunkInterface ChunkInterface(this);
if (a_BlockType == E_BLOCK_AIR)
@@ -1303,7 +1303,7 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a
-void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType)
+void cChunkMap::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType)
{
int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
cChunkDef::AbsoluteToRelative(X, Y, Z, ChunkX, ChunkZ);
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 4daa85ebd..973d0d219 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -154,9 +154,9 @@ public:
NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ);
- void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockMeta);
- void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true);
- void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR);
+ void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockMeta);
+ void SetBlock (cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true);
+ void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick, BLOCKTYPE a_PreviousBlockType = E_BLOCK_AIR);
bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
--
cgit v1.2.3
From dc5c43c0aa3ffb8ddaa0871ccf76d872d2393cdb Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 13 Jul 2014 01:04:43 +0200
Subject: Changed comments.
---
src/Mobs/Sheep.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 36d7df826..5ffd3e4fe 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -15,8 +15,9 @@ class cSheep :
public:
/** The number is the color of the sheep.
- 0-15 are the normal colors, if you type -1 the server
- automatically chooses the right color for the sheep when spawned. */
+ Use E_META_WOOL_* constants for the wool color.
+ If you type -1, the server will generate a random color
+ with the GenerateNaturalRandomColor() function. */
cSheep(int a_Color = -1);
CLASS_PROTODEF(cSheep);
@@ -27,7 +28,8 @@ public:
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
- /** Generates a random color for the sheep, like Mojang it does. */
+ /** Generates a random color for the sheep like the vanilla server.
+ The percent's where used are from the wiki: http://minecraft.gamepedia.com/Sheep#Breeding */
static NIBBLETYPE GenerateNaturalRandomColor(void);
bool IsSheared(void) const { return m_IsSheared; }
--
cgit v1.2.3
From e11f41d04821c9c00796066b45c4ace86415beb3 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 13 Jul 2014 00:12:32 +0100
Subject: Revert failed fix for #31
This reverts commit 69dc9b4c9aea58ebd95e2dbd0205701dfc4ce54e.
---
src/ClientHandle.cpp | 31 ++++---------------------------
src/ClientHandle.h | 4 ----
2 files changed, 4 insertions(+), 31 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index efa734b44..56275a9b2 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -40,9 +40,6 @@
/** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */
#define MAX_BLOCK_CHANGE_INTERACTIONS 20
-/** How many ticks before the socket is closed after the client is destroyed (#31) */
-static const int TICKS_BEFORE_CLOSE = 20;
-
@@ -79,7 +76,6 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
m_PingID(1),
m_BlockDigAnimStage(-1),
m_HasStartedDigging(false),
- m_TicksSinceDestruction(0),
m_State(csConnected),
m_ShouldCheckDownloaded(false),
m_NumExplosionsThisTick(0),
@@ -104,7 +100,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
cClientHandle::~cClientHandle()
{
- ASSERT(m_State >= csDestroyedWaiting); // Has Destroy() been called?
+ ASSERT(m_State == csDestroyed); // Has Destroy() been called?
LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this);
@@ -169,7 +165,7 @@ void cClientHandle::Destroy(void)
RemoveFromAllChunks();
m_Player->GetWorld()->RemoveClientFromChunkSender(this);
}
- m_State = csDestroyedWaiting;
+ m_State = csDestroyed;
}
@@ -1823,18 +1819,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void)
void cClientHandle::Tick(float a_Dt)
-{
- // Handle clients that are waiting for final close while destroyed:
- if (m_State == csDestroyedWaiting)
- {
- m_TicksSinceDestruction += 1; // This field is misused for the timeout counting
- if (m_TicksSinceDestruction > TICKS_BEFORE_CLOSE)
- {
- m_State = csDestroyed;
- }
- return;
- }
-
+{
// Process received network data:
AString IncomingData;
{
@@ -1900,15 +1885,7 @@ void cClientHandle::Tick(float a_Dt)
void cClientHandle::ServerTick(float a_Dt)
-{
- // Handle clients that are waiting for final close while destroyed:
- if (m_State == csDestroyedWaiting)
- {
- // Do not wait while the client is not in the world, simply cut them off.
- m_State = csDestroyed;
- return;
- }
-
+{
// Process received network data:
AString IncomingData;
{
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 6f2c86b27..b0bbda19e 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -325,9 +325,6 @@ private:
int m_LastDigBlockX;
int m_LastDigBlockY;
int m_LastDigBlockZ;
-
- /** Used while csDestroyedWaiting for counting the ticks until the connection is closed */
- int m_TicksSinceDestruction;
enum eState
{
@@ -338,7 +335,6 @@ private:
csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
csPlaying, ///< Normal gameplay
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
- csDestroyedWaiting, ///< The client has been destroyed, but is still kept so that the Kick packet is delivered (#31)
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
// TODO: Add Kicking here as well
--
cgit v1.2.3
From 6484e9814a3a540518606f552398e0b82f91ab4d Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Sun, 13 Jul 2014 00:16:49 +0100
Subject: Only one instance of server can be started
This disallows the UDP multicasting that the original code enabled.
xoft deterrent, in PR #1151 you implied that this was unwanted behaviour
(but comments gone now as I force pushed - check emails?).
Revert at will if unsatisfactory :P
---
src/Server.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/Server.cpp b/src/Server.cpp
index 5d1e51036..9220731eb 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -221,14 +221,12 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
bool HasAnyPorts = false;
AString Ports = a_SettingsIni.GetValueSet("Server", "Port", "25565");
- m_ListenThreadIPv4.SetReuseAddr(true);
if (m_ListenThreadIPv4.Initialize(Ports))
{
HasAnyPorts = true;
}
Ports = a_SettingsIni.GetValueSet("Server", "PortsIPv6", "25565");
- m_ListenThreadIPv6.SetReuseAddr(true);
if (m_ListenThreadIPv6.Initialize(Ports))
{
HasAnyPorts = true;
--
cgit v1.2.3
From f1491ad1d1df3e0b4d22af8329c95106e794ba01 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 13 Jul 2014 01:18:41 +0200
Subject: Fixed diamond mover plugin
---
MCServer/Plugins/DiamondMover/DiamondMover.lua | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/MCServer/Plugins/DiamondMover/DiamondMover.lua b/MCServer/Plugins/DiamondMover/DiamondMover.lua
index 0fdd32250..d3e70acfc 100644
--- a/MCServer/Plugins/DiamondMover/DiamondMover.lua
+++ b/MCServer/Plugins/DiamondMover/DiamondMover.lua
@@ -22,6 +22,8 @@ function Initialize(Plugin)
Plugin:SetVersion(1);
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USED_ITEM, OnPlayerUsedItem);
+
+ LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion());
return true;
end
@@ -36,8 +38,8 @@ function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cu
return false;
end;
- if (Player:HasPermission("diamondmover.move") == false) then
- return true;
+ if (not Player:HasPermission("diamondmover.move")) then
+ return false;
end;
-- Rclk with a diamond to push in the direction the player is facing
@@ -56,7 +58,7 @@ function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, Cu
if (PlayerPitch > 70) then -- looking down
BlockY = BlockY - 1;
else
- local PlayerRot = Player:GetRotation() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions
+ local PlayerRot = Player:GetYaw() + 180; -- Convert [-180, 180] into [0, 360] for simpler conditions
if ((PlayerRot < 45) or (PlayerRot > 315)) then
BlockZ = BlockZ - 1;
else
--
cgit v1.2.3
From d529971e279609ae928d9077404b95bd595b5e52 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 13 Jul 2014 02:08:02 +0200
Subject: Changed BroadcastSoundEffect function to take floating pos.
---
src/BlockEntities/NoteEntity.cpp | 2 +-
src/Blocks/BlockButton.h | 2 +-
src/Blocks/BlockLever.h | 2 +-
src/Blocks/BlockPiston.cpp | 4 ++--
src/Blocks/BroadcastInterface.h | 2 +-
src/Chunk.cpp | 4 ++--
src/Chunk.h | 2 +-
src/ChunkMap.cpp | 6 +++---
src/ChunkMap.h | 2 +-
src/ClientHandle.cpp | 6 +++---
src/ClientHandle.h | 2 +-
src/Entities/ArrowEntity.cpp | 6 +++---
src/Entities/ExpOrb.cpp | 2 +-
src/Entities/Floater.cpp | 2 +-
src/Entities/Pickup.cpp | 2 +-
src/Entities/Player.cpp | 2 +-
src/Items/ItemBow.h | 2 +-
src/Items/ItemLighter.h | 6 +++---
src/Items/ItemThrowable.h | 9 +--------
src/Mobs/Creeper.cpp | 4 ++--
src/Mobs/Monster.cpp | 4 ++--
src/Protocol/Protocol.h | 2 +-
src/Protocol/Protocol125.cpp | 2 +-
src/Protocol/Protocol125.h | 2 +-
src/Protocol/Protocol132.cpp | 19 ++++++++-----------
src/Protocol/Protocol132.h | 2 +-
src/Protocol/Protocol17x.cpp | 14 +++++++++-----
src/Protocol/Protocol17x.h | 2 +-
src/Protocol/ProtocolRecognizer.cpp | 4 ++--
src/Protocol/ProtocolRecognizer.h | 2 +-
src/Simulator/FloodyFluidSimulator.cpp | 4 ++--
src/Simulator/IncrementalRedstoneSimulator.cpp | 14 +++++++-------
src/Simulator/VaporizeFluidSimulator.cpp | 2 +-
src/UI/Window.cpp | 10 +++++-----
src/World.cpp | 6 +++---
src/World.h | 2 +-
36 files changed, 77 insertions(+), 83 deletions(-)
diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp
index 58b05a324..95145c117 100644
--- a/src/BlockEntities/NoteEntity.cpp
+++ b/src/BlockEntities/NoteEntity.cpp
@@ -91,7 +91,7 @@ void cNoteEntity::MakeSound(void)
// TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
float calcPitch = pow(2.0f, ((float)m_Pitch - 12.0f) / 12.0f);
- m_World->BroadcastSoundEffect(sampleName, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 3.0f, calcPitch);
+ m_World->BroadcastSoundEffect(sampleName, (double)m_PosX, (double)m_PosY, (double)m_PosZ, 3.0f, calcPitch);
}
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index ada7d58f7..7f92681dc 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -24,7 +24,7 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
// Queue a button reset (unpress)
a_ChunkInterface.QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 30, m_BlockType, a_WorldInterface);
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 4e745d413..7ce8d038e 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -24,7 +24,7 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp
index 6f8d8be3e..ec480aaea 100644
--- a/src/Blocks/BlockPiston.cpp
+++ b/src/Blocks/BlockPiston.cpp
@@ -124,7 +124,7 @@ void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ,
}
a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock);
- a_World->BroadcastSoundEffect("tile.piston.out", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f);
+ a_World->BroadcastSoundEffect("tile.piston.out", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
// Drop the breakable block in the line, if appropriate:
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1); // "a_Block" now at the breakable / empty block
@@ -198,7 +198,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8));
a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock);
- a_World->BroadcastSoundEffect("tile.piston.in", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.7f);
+ a_World->BroadcastSoundEffect("tile.piston.in", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
// Retract the extension, pull block if appropriate
diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h
index b1b450690..fbe72e72f 100644
--- a/src/Blocks/BroadcastInterface.h
+++ b/src/Blocks/BroadcastInterface.h
@@ -7,6 +7,6 @@ public:
virtual ~cBroadcastInterface() {}
virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) = 0;
- virtual void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0;
+ virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) = 0;
virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) = 0;
};
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index c004a6408..8a249ea53 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -2956,7 +2956,7 @@ void cChunk::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI
-void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunk::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2964,7 +2964,7 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a
{
continue;
}
- (*itr)->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ (*itr)->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
} // for itr - LoadedByClient[]
}
diff --git a/src/Chunk.h b/src/Chunk.h
index 90664b513..dfcfdab0f 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -298,7 +298,7 @@ public:
void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
- void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
+ void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 35d55d396..2253c5877 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -647,19 +647,19 @@ void cChunkMap::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_Effe
-void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcZ / 8, ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk(std::floor(a_X), std::floor(a_Z), ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
if (Chunk == NULL)
{
return;
}
// It's perfectly legal to broadcast packets even to invalid chunks!
- Chunk->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
+ Chunk->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude);
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 4daa85ebd..a9ee006fd 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -85,7 +85,7 @@ public:
void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL);
void BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount, cClientHandle * a_Exclude = NULL);
void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL);
- void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
+ void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL);
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 56275a9b2..340db6394 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1361,7 +1361,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
// Step sound with 0.8f pitch is used as block placement sound
- World->BroadcastSoundEffect(NewBlock->GetStepSound(), a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f);
+ World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f);
cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
}
@@ -2426,9 +2426,9 @@ void cClientHandle::SendDisplayObjective(const AString & a_Objective, cScoreboar
-void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
- m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index b0bbda19e..922740b11 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -162,7 +162,7 @@ public:
void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode);
void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display);
- void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
+ void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch); // tolua_export
void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
void SendSpawnMob (const cMonster & a_Mob);
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index d59088e72..d5e41bd46 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -89,7 +89,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
- m_World->BroadcastSoundEffect("random.bowhit", X * 8, Y * 8, Z * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.bowhit", (double)X, (double)Y, (double)Z, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
@@ -106,7 +106,7 @@ void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
// Broadcast successful hit sound
- GetWorld()->BroadcastSoundEffect("random.successful_hit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
@@ -131,7 +131,7 @@ void cArrowEntity::CollectedBy(cPlayer * a_Dest)
}
GetWorld()->BroadcastCollectEntity(*this, *a_Dest);
- GetWorld()->BroadcastSoundEffect("random.pop", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsCollected = true;
}
}
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 10f79aedc..e437c24ef 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -56,7 +56,7 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
a_ClosestPlayer->DeltaExperience(m_Reward);
- m_World->BroadcastSoundEffect("random.orb", (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.orb", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
Destroy();
}
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index b910c3769..d49893020 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -134,7 +134,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_CountDownTime <= 0)
{
- m_World->BroadcastSoundEffect("random.splash", (int) floor(GetPosX() * 8), (int) floor(GetPosY() * 8), (int) floor(GetPosZ() * 8), 1, 1);
+ m_World->BroadcastSoundEffect("random.splash", GetPosX(), GetPosY(), GetPosZ(), 1, 1);
SetPosY(GetPosY() - 1);
m_CanPickupItem = true;
m_PickupCountDown = 20;
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 24fa591da..bae1485d4 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -226,7 +226,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
m_Item.m_ItemCount -= NumAdded;
m_World->BroadcastCollectEntity(*this, *a_Dest);
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- m_World->BroadcastSoundEffect("random.pop",(int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
if (m_Item.m_ItemCount <= 0)
{
// All of the pickup has been collected, schedule the pickup for destroying
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 944ed643e..b1b7fc74e 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1937,7 +1937,7 @@ void cPlayer::UseEquippedItem(void)
if (GetInventory().DamageEquippedItem())
{
- m_World->BroadcastSoundEffect("random.break", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index 185f17fee..e7a77dcbc 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -70,7 +70,7 @@ public:
return;
}
- a_Player->GetWorld()->BroadcastSoundEffect("random.bow", (int)a_Player->GetPosX() * 8, (int)a_Player->GetPosY() * 8, (int)a_Player->GetPosZ() * 8, 0.5, (float)Force);
+ a_Player->GetWorld()->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY(), a_Player->GetPosZ(), 0.5, (float)Force);
if (!a_Player->IsGameModeCreative())
{
a_Player->UseEquippedItem();
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 32f49cab6..9f98bf85f 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -52,8 +52,8 @@ public:
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 1.0f);
- a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
+ a_World->BroadcastSoundEffect("game.tnt.primed", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 1.0f);
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
break;
}
@@ -68,7 +68,7 @@ public:
if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("fire.ignite", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0F, 1.04F);
+ a_World->BroadcastSoundEffect("fire.ignite", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0F, 1.04F);
break;
}
}
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index 25935a1bc..fde7b8e67 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -33,14 +33,7 @@ public:
// Play sound
cFastRandom Random;
- a_World->BroadcastSoundEffect(
- "random.bow",
- (int)std::floor(a_Player->GetPosX() * 8.0),
- (int)std::floor((a_Player->GetPosY() - a_Player->GetHeight()) * 8.0),
- (int)std::floor(a_Player->GetPosZ() * 8.0),
- 0.5F,
- 0.4F / (Random.NextFloat(1.0F) * 0.4F + 0.8F)
- );
+ a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f));
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0)
{
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index b9041bd5a..8ab09a4c5 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -125,7 +125,7 @@ void cCreeper::Attack(float a_Dt)
if (!m_bIsBlowing)
{
- m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
}
@@ -143,7 +143,7 @@ void cCreeper::OnRightClicked(cPlayer & a_Player)
{
a_Player.UseEquippedItem();
}
- m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
m_BurnedWithFlintAndSteel = true;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index aaef7580d..6d6364404 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -478,7 +478,7 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
if (!m_SoundHurt.empty() && (m_Health > 0))
{
- m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
+ m_World->BroadcastSoundEffect(m_SoundHurt, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
}
if (a_TDI.Attacker != NULL)
@@ -497,7 +497,7 @@ void cMonster::KilledBy(cEntity * a_Killer)
super::KilledBy(a_Killer);
if (m_SoundHurt != "")
{
- m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
+ m_World->BroadcastSoundEffect(m_SoundDeath, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
}
int Reward;
switch (m_MobType)
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index ac872a2f2..dc35a6653 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -106,7 +106,7 @@ public:
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) = 0;
virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) = 0;
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) = 0;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) = 0;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 6dc2e918d..28fdcf23a 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -899,7 +899,7 @@ void cProtocol125::SendScoreboardObjective(const AString & a_Name, const AString
-void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cProtocol125::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
// Not needed in this protocol version
}
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 9dbefd3a3..86a49f3f6 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -78,7 +78,7 @@ public:
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override {} // This protocol doesn't support such message
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override {} // This protocol doesn't support such message
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp
index 31cf99f53..b2b84953c 100644
--- a/src/Protocol/Protocol132.cpp
+++ b/src/Protocol/Protocol132.cpp
@@ -195,13 +195,6 @@ void cProtocol132::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a
WriteInt (a_Entity.GetUniqueID());
WriteInt (a_Player.GetUniqueID());
Flush();
-
- // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
- SendSoundEffect(
- "random.pop",
- (int)(a_Entity.GetPosX() * 8), (int)(a_Entity.GetPosY() * 8), (int)(a_Entity.GetPosZ() * 8),
- 0.5, (float)(0.75 + ((float)((a_Entity.GetUniqueID() * 23) % 32)) / 64)
- );
}
@@ -285,14 +278,18 @@ void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player)
-void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cProtocol132::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
+ int SrcX = std::floor(a_X * 8.0);
+ int SrcY = std::floor(a_Y * 8.0);
+ int SrcZ = std::floor(a_Z * 8.0);
+
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_SOUND_EFFECT);
WriteString (a_SoundName);
- WriteInt (a_SrcX);
- WriteInt (a_SrcY);
- WriteInt (a_SrcZ);
+ WriteInt (SrcX);
+ WriteInt (SrcY);
+ WriteInt (SrcZ);
WriteFloat (a_Volume);
WriteChar ((char)(a_Pitch * 63.0f));
Flush();
diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h
index e5d3ee80c..1124a7253 100644
--- a/src/Protocol/Protocol132.h
+++ b/src/Protocol/Protocol132.h
@@ -53,7 +53,7 @@ public:
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
virtual void SendTabCompletionResults(const AStringVector & a_Results) override;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 855687269..ae077d69e 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1084,15 +1084,19 @@ void cProtocol172::SendDisplayObjective(const AString & a_Objective, cScoreboard
-void cProtocol172::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) // a_Src coords are Block * 8
+void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
-
+
+ int SrcX = std::floor(a_X * 8.0);
+ int SrcY = std::floor(a_Y * 8.0);
+ int SrcZ = std::floor(a_Z * 8.0);
+
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
Pkt.WriteString(a_SoundName);
- Pkt.WriteInt(a_SrcX);
- Pkt.WriteInt(a_SrcY);
- Pkt.WriteInt(a_SrcZ);
+ Pkt.WriteInt(SrcX);
+ Pkt.WriteInt(SrcY);
+ Pkt.WriteInt(SrcZ);
Pkt.WriteFloat(a_Volume);
Pkt.WriteByte((Byte)(a_Pitch * 63));
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 1a65cfa1c..e635a62c1 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -105,7 +105,7 @@ public:
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks = false) override;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendExperience (void) override;
virtual void SendExperienceOrb (const cExpOrb & a_ExpOrb) override;
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index c0c9e08ee..29f4576cd 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -616,10 +616,10 @@ void cProtocolRecognizer::SendDisplayObjective(const AString & a_Objective, cSco
-void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
+void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
ASSERT(m_Protocol != NULL);
- m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
+ m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 0a9a42e93..e5ec3ece2 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -113,7 +113,7 @@ public:
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
virtual void SendScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) override;
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
- virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
+ virtual void SendSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index 4ffda2365..d8de19871 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -254,7 +254,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
);
a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
- a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f);
+ a_NearChunk->BroadcastSoundEffect("random.fizz", (double)BlockX, (double)a_RelY, (double)BlockZ, 0.5f, 1.5f);
return;
}
}
@@ -269,7 +269,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
);
a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
- a_NearChunk->BroadcastSoundEffect("random.fizz", BlockX * 8, a_RelY * 8, BlockZ * 8, 0.5f, 1.5f);
+ a_NearChunk->BroadcastSoundEffect("random.fizz", (double)BlockX, (double)a_RelY, (double)BlockZ, 0.5f, 1.5f);
return;
}
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 3c037b6db..8b9d830cd 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -881,7 +881,7 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_RelBlockX, int a_RelBlockY,
if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
- m_Chunk->BroadcastSoundEffect("game.tnt.primed", BlockX * 8, a_RelBlockY * 8, BlockZ * 8, 0.5f, 0.6f);
+ m_Chunk->BroadcastSoundEffect("game.tnt.primed", (double)BlockX, (double)a_RelBlockY, (double)BlockZ, 0.5f, 0.6f);
m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_AIR, 0);
m_World.SpawnPrimedTNT(BlockX + 0.5, a_RelBlockY + 0.5, BlockZ + 0.5); // 80 ticks to boom
}
@@ -1159,7 +1159,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power);
@@ -1169,7 +1169,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
@@ -1227,7 +1227,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Power);
@@ -1237,7 +1237,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
@@ -1294,7 +1294,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_RAISED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.5F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.5F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_DEPRESSED);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
@@ -1304,7 +1304,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
{
if (Meta == E_META_PRESSURE_PLATE_DEPRESSED)
{
- m_Chunk->BroadcastSoundEffect("random.click", (int)((BlockX + 0.5) * 8.0), (int)((a_RelBlockY + 0.1) * 8.0), (int)((BlockZ + 0.5) * 8.0), 0.3F, 0.6F);
+ m_Chunk->BroadcastSoundEffect("random.click", (double)BlockX + 0.5, (double)a_RelBlockY + 0.1, (double)BlockZ + 0.5, 0.3F, 0.6F);
}
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_META_PRESSURE_PLATE_RAISED);
SetSourceUnpowered(BlockX, a_RelBlockY, BlockZ, m_Chunk);
diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp
index 4206c64d1..191770273 100644
--- a/src/Simulator/VaporizeFluidSimulator.cpp
+++ b/src/Simulator/VaporizeFluidSimulator.cpp
@@ -35,7 +35,7 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
)
{
a_Chunk->SetBlock(RelX, a_BlockY, RelZ, E_BLOCK_AIR, 0);
- a_Chunk->BroadcastSoundEffect("random.fizz", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.6f);
+ a_Chunk->BroadcastSoundEffect("random.fizz", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f);
}
}
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 43d923fa5..19db01b7a 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -918,7 +918,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
// Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
@@ -944,7 +944,7 @@ cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_Secon
m_ShouldDistributeToHotbarFirst = false;
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
// Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
@@ -1004,7 +1004,7 @@ cChestWindow::~cChestWindow()
// Send out the chest-close packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
- m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
}
@@ -1042,7 +1042,7 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
// Play the opening sound:
- m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
// Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST);
@@ -1058,7 +1058,7 @@ cEnderChestWindow::~cEnderChestWindow()
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST);
// Play the closing sound
- m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1);
+ m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
}
diff --git a/src/World.cpp b/src/World.cpp
index 64a629233..46a193d4f 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1088,7 +1088,7 @@ void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_Blo
Vector3d explosion_pos = Vector3d(a_BlockX, a_BlockY, a_BlockZ);
cVector3iArray BlocksAffected;
m_ChunkMap->DoExplosionAt(a_ExplosionSize, a_BlockX, a_BlockY, a_BlockZ, BlocksAffected);
- BroadcastSoundEffect("random.explode", (int)floor(a_BlockX * 8), (int)floor(a_BlockY * 8), (int)floor(a_BlockZ * 8), 1.0f, 0.6f);
+ BroadcastSoundEffect("random.explode", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.6f);
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -2074,9 +2074,9 @@ void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard:
-void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
+void cWorld::BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
- m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);
+ m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch, a_Exclude);
}
diff --git a/src/World.h b/src/World.h
index 27dd81be3..be055f004 100644
--- a/src/World.h
+++ b/src/World.h
@@ -224,7 +224,7 @@ public:
void BroadcastScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode);
void BroadcastScoreUpdate (const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode);
void BroadcastDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display);
- void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export a_Src coords are Block * 8
+ void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // tolua_export
void BroadcastSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL); // tolua_export
void BroadcastSpawnEntity (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastTeleportEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
--
cgit v1.2.3
From 9b0b57bcbc9239f65ebfacf9df904d2bb77d2355 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Sun, 13 Jul 2014 11:11:40 +0200
Subject: Update.
---
src/Mobs/Sheep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index e208aa891..019f9e6a2 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -62,7 +62,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
- m_World->BroadcastSoundEffect("mob.sheep.shear", POSX_TOINT * 8, POSY_TOINT * 8, POSZ_TOINT * 8, 1.0f, 1.0f);
+ m_World->BroadcastSoundEffect("mob.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f);
}
else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
{
--
cgit v1.2.3
From 31415aec63f03aeb92ec17ad3a3acb27aa6b2fc2 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sun, 13 Jul 2014 13:31:09 +0200
Subject: Fixed MSVC warnings in SoundEffect functions.
---
src/ChunkMap.cpp | 2 +-
src/Protocol/Protocol132.cpp | 10 +++-------
src/Protocol/Protocol17x.cpp | 10 +++-------
3 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 0a0a841cd..b24eead2d 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -652,7 +652,7 @@ void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, double a_X, do
cCSLock Lock(m_CSLayers);
int ChunkX, ChunkZ;
- cChunkDef::BlockToChunk(std::floor(a_X), std::floor(a_Z), ChunkX, ChunkZ);
+ cChunkDef::BlockToChunk((int)std::floor(a_X), (int)std::floor(a_Z), ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
if (Chunk == NULL)
{
diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp
index b2b84953c..7a8c2221e 100644
--- a/src/Protocol/Protocol132.cpp
+++ b/src/Protocol/Protocol132.cpp
@@ -280,16 +280,12 @@ void cProtocol132::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocol132::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
- int SrcX = std::floor(a_X * 8.0);
- int SrcY = std::floor(a_Y * 8.0);
- int SrcZ = std::floor(a_Z * 8.0);
-
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_SOUND_EFFECT);
WriteString (a_SoundName);
- WriteInt (SrcX);
- WriteInt (SrcY);
- WriteInt (SrcZ);
+ WriteInt ((int)(a_X * 8.0));
+ WriteInt ((int)(a_Y * 8.0));
+ WriteInt ((int)(a_Z * 8.0));
WriteFloat (a_Volume);
WriteChar ((char)(a_Pitch * 63.0f));
Flush();
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index ae077d69e..dc6a817a3 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1088,15 +1088,11 @@ void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, doub
{
ASSERT(m_State == 3); // In game mode?
- int SrcX = std::floor(a_X * 8.0);
- int SrcY = std::floor(a_Y * 8.0);
- int SrcZ = std::floor(a_Z * 8.0);
-
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
Pkt.WriteString(a_SoundName);
- Pkt.WriteInt(SrcX);
- Pkt.WriteInt(SrcY);
- Pkt.WriteInt(SrcZ);
+ Pkt.WriteInt((int)(a_X * 8.0));
+ Pkt.WriteInt((int)(a_Y * 8.0));
+ Pkt.WriteInt((int)(a_Z * 8.0));
Pkt.WriteFloat(a_Volume);
Pkt.WriteByte((Byte)(a_Pitch * 63));
}
--
cgit v1.2.3
From bfc485bfe2093dde665bc17588ea53218f964312 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 13 Jul 2014 15:05:54 +0100
Subject: Fix CopyPaste error that ment a_MaxRelX wasdn't checked
Fixes CID 70464
---
src/Generating/ChunkDesc.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 7711723fc..570332615 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -290,7 +290,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelX = 0;
}
- else if (a_MinRelX >= cChunkDef::Width)
+ else if (a_MaxRelX >= cChunkDef::Width)
{
LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MaxRelX = cChunkDef::Width - 1;
--
cgit v1.2.3
From 4a6d606f7499582e6ec2953e663e98153a19a613 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 13 Jul 2014 14:09:08 +0100
Subject: Made CreateProjectile a pointer
---
src/Entities/ProjectileEntity.cpp | 7 ++++---
src/Entities/ProjectileEntity.h | 2 +-
src/World.cpp | 2 +-
src/World.h | 2 +-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 0bb34019e..b5ef5c90a 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -243,7 +243,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve
-cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item, const Vector3d * a_Speed)
+cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed)
{
Vector3d Speed;
if (a_Speed != NULL)
@@ -262,12 +262,13 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
case pkExpBottle: return new cExpBottleEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFirework:
{
- if (a_Item.m_FireworkItem.m_Colours.empty())
+ ASSERT(a_Item != NULL);
+ if (a_Item->m_FireworkItem.m_Colours.empty())
{
return NULL;
}
- return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, a_Item);
+ return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, *a_Item);
}
}
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 7b38169e2..14cee1272 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -46,7 +46,7 @@ public:
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
- static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item, const Vector3d * a_Speed = NULL);
+ static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL);
/// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
diff --git a/src/World.cpp b/src/World.cpp
index 46a193d4f..ba8add8f0 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2998,7 +2998,7 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster)
-int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem & a_Item, const Vector3d * a_Speed)
+int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed)
{
cProjectileEntity * Projectile = cProjectileEntity::Create(a_Kind, a_Creator, a_PosX, a_PosY, a_PosZ, a_Item, a_Speed);
if (Projectile == NULL)
diff --git a/src/World.h b/src/World.h
index be055f004..5bb0e640f 100644
--- a/src/World.h
+++ b/src/World.h
@@ -751,7 +751,7 @@ public:
/** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise
Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata
*/
- int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem & a_Item, const Vector3d * a_Speed = NULL); // tolua_export
+ int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = NULL); // tolua_export
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
int GetTickRandomNumber(unsigned a_Range) { return (int)(m_TickRand.randInt(a_Range)); }
--
cgit v1.2.3
From 2a0c041ad8eaa42e4293762df18d14c77e11ea49 Mon Sep 17 00:00:00 2001
From: Tycho
Date: Sun, 13 Jul 2014 15:25:52 +0100
Subject: Adjusted calls to CreateProjectile that passed Items
---
lib/polarssl | 2 +-
src/Items/ItemThrowable.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/polarssl b/lib/polarssl
index 1ed82759c..784b04ff9 160000
--- a/lib/polarssl
+++ b/lib/polarssl
@@ -1 +1 @@
-Subproject commit 1ed82759c68f92c4acc7e3f33b850cf9f01c8aba
+Subproject commit 784b04ff9afd5faeaeb15c3fa159ff98adf55182
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index fde7b8e67..c151c5d3a 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -35,7 +35,7 @@ public:
cFastRandom Random;
a_World->BroadcastSoundEffect("random.bow", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f));
- if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, a_Player->GetEquippedItem(), &Speed) < 0)
+ if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) < 0)
{
return false;
}
@@ -135,7 +135,7 @@ public:
return false;
}
- if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, a_Player->GetEquippedItem()) < 0)
+ if (a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem()) < 0)
{
return false;
}
--
cgit v1.2.3
From 64697f0cabeeadf1d50717892f0815d8309f8b8a Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 13 Jul 2014 15:29:43 +0100
Subject: Another COpyPaste Error
Fixes CID 70461
---
src/Generating/ChunkDesc.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 570332615..c63ca6689 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -332,7 +332,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelZ = 0;
}
- else if (a_MinRelZ >= cChunkDef::Width)
+ else if (a_MaxRelZ >= cChunkDef::Width)
{
LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MaxRelZ = cChunkDef::Width - 1;
--
cgit v1.2.3
From 132b367316b2723ef573476a9fb78bcba6f09294 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 13 Jul 2014 15:32:44 +0100
Subject: CopyPaste Error
Fixes CID 70460.
---
src/Generating/ChunkDesc.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index c63ca6689..e4b305022 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -311,7 +311,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelY = 0;
}
- else if (a_MinRelY >= cChunkDef::Height)
+ else if (a_MaxRelY >= cChunkDef::Height)
{
LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
a_MaxRelY = cChunkDef::Height - 1;
--
cgit v1.2.3
From e1a561286a47ab52f4402ae9d08f143d26c60402 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 13 Jul 2014 15:01:49 +0100
Subject: Fixed Issue with Comparing agast the wrong chest, potentially causing
crashes.
---
src/BlockEntities/HopperEntity.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index aaf82d150..7af4b9d5d 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -368,13 +368,13 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
/// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{
- cChestEntity * Chest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
- if (Chest == NULL)
+ cChestEntity * MainChest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
+ if (MainChest == NULL)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false;
}
- if (MoveItemsFromGrid(*Chest))
+ if (MoveItemsFromGrid(*MainChest))
{
// Moved the item from the chest directly above the hopper
return true;
@@ -403,20 +403,20 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
}
BLOCKTYPE Block = Neighbor->GetBlock(x, m_PosY + 1, z);
- if (Block != Chest->GetBlockType())
+ if (Block != MainChest->GetBlockType())
{
// Not the same kind of chest
continue;
}
- Chest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
- if (Chest == NULL)
+ cChestEntity * SideChest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
+ if (SideChest == NULL)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
}
else
{
- if (MoveItemsFromGrid(*Chest))
+ if (MoveItemsFromGrid(*SideChest))
{
return true;
}
--
cgit v1.2.3
From 4315deb90b62a40a07bf4f3427b52a613738c102 Mon Sep 17 00:00:00 2001
From: worktycho
Date: Sun, 13 Jul 2014 16:07:35 +0100
Subject: Added parenthasies
---
src/ChunkMap.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index f0222c0f5..164b7d37a 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1530,7 +1530,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player)
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ);
- if (Chunk != NULL && Chunk->IsValid())
+ if ((Chunk != NULL) && (Chunk->IsValid()))
{
Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle());
}
--
cgit v1.2.3
From 8bb0baa842727bd2b8cb22775b18f7a5c3dad57e Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Sun, 13 Jul 2014 17:07:30 +0200
Subject: Tolua driver: Fixed wrong indentation.
---
lib/tolua++/src/bin/lua/_driver.lua | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/lib/tolua++/src/bin/lua/_driver.lua b/lib/tolua++/src/bin/lua/_driver.lua
index 21db96098..87ecd42ea 100644
--- a/lib/tolua++/src/bin/lua/_driver.lua
+++ b/lib/tolua++/src/bin/lua/_driver.lua
@@ -6,21 +6,21 @@ if mobdebugfound then mobdebug.start() end
-- The list of valid arguments that the ToLua scripts can process:
local KnownArgs = {
['v'] = true,
- ['h'] = true,
- ['p'] = true,
- ['P'] = true,
- ['o'] = true,
- ['n'] = true,
- ['H'] = true,
- ['S'] = true,
- ['1'] = true,
- ['L'] = true,
- ['D'] = true,
- ['W'] = true,
- ['C'] = true,
- ['E'] = true,
- ['t'] = true,
- ['q'] = true,
+ ['h'] = true,
+ ['p'] = true,
+ ['P'] = true,
+ ['o'] = true,
+ ['n'] = true,
+ ['H'] = true,
+ ['S'] = true,
+ ['1'] = true,
+ ['L'] = true,
+ ['D'] = true,
+ ['W'] = true,
+ ['C'] = true,
+ ['E'] = true,
+ ['t'] = true,
+ ['q'] = true,
}
--
cgit v1.2.3
From f77723128c6582e9c184706c7140c8bcf9c390c4 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 13 Jul 2014 15:23:23 -0700
Subject: Changed separating comment style from asterisks to slashes.
---
src/Entities/EntityEffect.cpp | 48 +++++++--------
src/Entities/EntityEffect.h | 138 +++++++++++++++++++++---------------------
2 files changed, 93 insertions(+), 93 deletions(-)
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index e68ded8b0..be501297c 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -106,9 +106,9 @@ void cEntityEffect::OnDeactivate(cPawn & a_Target)
-/************************************************************************
- **** Instant Health
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Instant Health
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
@@ -129,9 +129,9 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
-/************************************************************************
- **** Instant Damage
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Instant Damage
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
@@ -152,9 +152,9 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
-/************************************************************************
- **** Regeneration
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Regeneration
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -182,9 +182,9 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
-/************************************************************************
- **** Hunger
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Hunger
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectHunger::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -200,9 +200,9 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target)
-/************************************************************************
- **** Weakness
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Weakness
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectWeakness::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -218,9 +218,9 @@ void cEntityEffectWeakness::OnTick(cPawn & a_Target)
-/************************************************************************
- **** Poison
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Poison
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectPoison::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -255,9 +255,9 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
-/************************************************************************
- **** Wither
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Wither
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectWither::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -276,9 +276,9 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
-/************************************************************************
- **** Saturation
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Saturation
+/////////////////////////////////////////////////////////////////////////
void cEntityEffectSaturation::OnTick(cPawn & a_Target)
{
if (a_Target.IsPlayer())
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index c593fba81..6e53d83b8 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -87,9 +87,9 @@ protected:
double m_DistanceModifier;
};
-/************************************************************************
- **** Speed
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Speed
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectSpeed:
public cEntityEffect
{
@@ -101,9 +101,9 @@ public:
}
};
-/************************************************************************
- **** Slowness
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Slowness
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectSlowness:
public cEntityEffect
{
@@ -115,9 +115,9 @@ public:
}
};
-/************************************************************************
- **** Haste
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Haste
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectHaste:
public cEntityEffect
{
@@ -129,9 +129,9 @@ public:
}
};
-/************************************************************************
- **** Mining Fatigue
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Mining Fatigue
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectMiningFatigue:
public cEntityEffect
{
@@ -143,9 +143,9 @@ public:
}
};
-/************************************************************************
- **** Strength
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Strength
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectStrength:
public cEntityEffect
{
@@ -157,9 +157,9 @@ public:
}
};
-/************************************************************************
- **** Instant Health
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Instant Health
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectInstantHealth:
public cEntityEffect
{
@@ -173,9 +173,9 @@ public:
virtual void OnActivate(cPawn & a_Target) override;
};
-/************************************************************************
- **** Instant Damage
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Instant Damage
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectInstantDamage:
public cEntityEffect
{
@@ -189,9 +189,9 @@ public:
virtual void OnActivate(cPawn & a_Target) override;
};
-/************************************************************************
- **** Jump Boost
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Jump Boost
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectJumpBoost:
public cEntityEffect
{
@@ -203,9 +203,9 @@ public:
}
};
-/************************************************************************
- **** Nausea
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Nausea
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectNausea:
public cEntityEffect
{
@@ -217,9 +217,9 @@ public:
}
};
-/************************************************************************
- **** Regeneration
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Regeneration
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectRegeneration:
public cEntityEffect
{
@@ -233,9 +233,9 @@ public:
virtual void OnTick(cPawn & a_Target) override;
};
-/************************************************************************
- **** Resistance
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Resistance
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectResistance:
public cEntityEffect
{
@@ -247,9 +247,9 @@ public:
}
};
-/************************************************************************
- **** Fire Resistance
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Fire Resistance
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectFireResistance:
public cEntityEffect
{
@@ -261,9 +261,9 @@ public:
}
};
-/************************************************************************
- **** Water Breathing
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Water Breathing
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectWaterBreathing:
public cEntityEffect
{
@@ -275,9 +275,9 @@ public:
}
};
-/************************************************************************
- **** Invisibility
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Invisibility
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectInvisibility:
public cEntityEffect
{
@@ -289,9 +289,9 @@ public:
}
};
-/************************************************************************
- **** Blindness
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Blindness
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectBlindness:
public cEntityEffect
{
@@ -303,9 +303,9 @@ public:
}
};
-/************************************************************************
- **** Night Vision
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Night Vision
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectNightVision:
public cEntityEffect
{
@@ -317,9 +317,9 @@ public:
}
};
-/************************************************************************
- **** Hunger
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Hunger
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectHunger:
public cEntityEffect
{
@@ -333,9 +333,9 @@ public:
virtual void OnTick(cPawn & a_Target) override;
};
-/************************************************************************
- **** Weakness
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Weakness
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectWeakness:
public cEntityEffect
{
@@ -349,9 +349,9 @@ public:
virtual void OnTick(cPawn & a_Target) override;
};
-/************************************************************************
- **** Poison
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Poison
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectPoison:
public cEntityEffect
{
@@ -365,9 +365,9 @@ public:
virtual void OnTick(cPawn & a_Target) override;
};
-/************************************************************************
- **** Wither
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Wither
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectWither:
public cEntityEffect
{
@@ -381,9 +381,9 @@ public:
virtual void OnTick(cPawn & a_Target) override;
};
-/************************************************************************
- **** Health Boost
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Health Boost
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectHealthBoost:
public cEntityEffect
{
@@ -395,9 +395,9 @@ public:
}
};
-/************************************************************************
- **** Absorption
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Absorption
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectAbsorption:
public cEntityEffect
{
@@ -409,9 +409,9 @@ public:
}
};
-/************************************************************************
- **** Saturation
- ************************************************************************/
+/////////////////////////////////////////////////////////////////////////
+// Saturation
+/////////////////////////////////////////////////////////////////////////
class cEntityEffectSaturation:
public cEntityEffect
{
--
cgit v1.2.3
From 0409daf7360d503e9e2b6258fa2582d7bdd7e5a0 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 13 Jul 2014 15:43:49 -0700
Subject: EntityEffect: Inlined functions, added explicit copy constructor and
operator.
---
src/Entities/EntityEffect.cpp | 35 ++++++++++++++++++-----------------
src/Entities/EntityEffect.h | 14 +++++++++++---
2 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index be501297c..852099b79 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -33,7 +33,11 @@ cEntityEffect::cEntityEffect(int a_Duration, short a_Intensity, double a_Distanc
-cEntityEffect::~cEntityEffect()
+cEntityEffect::cEntityEffect(const cEntityEffect & a_OtherEffect):
+ m_Ticks(a_OtherEffect.m_Ticks),
+ m_Duration(a_OtherEffect.m_Duration),
+ m_Intensity(a_OtherEffect.m_Intensity),
+ m_DistanceModifier(a_OtherEffect.m_DistanceModifier)
{
}
@@ -42,6 +46,19 @@ cEntityEffect::~cEntityEffect()
+cEntityEffect & cEntityEffect::operator=(cEntityEffect a_OtherEffect)
+{
+ std::swap(m_Ticks, a_OtherEffect.m_Ticks);
+ std::swap(m_Duration, a_OtherEffect.m_Duration);
+ std::swap(m_Intensity, a_OtherEffect.m_Intensity);
+ std::swap(m_DistanceModifier, a_OtherEffect.m_DistanceModifier);
+ return *this;
+}
+
+
+
+
+
cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
{
switch (a_EffectType)
@@ -90,22 +107,6 @@ void cEntityEffect::OnTick(cPawn & a_Target)
-void cEntityEffect::OnActivate(cPawn & a_Target)
-{
-}
-
-
-
-
-
-void cEntityEffect::OnDeactivate(cPawn & a_Target)
-{
-}
-
-
-
-
-
/////////////////////////////////////////////////////////////////////////
// Instant Health
/////////////////////////////////////////////////////////////////////////
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index 6e53d83b8..c6532a9bd 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -45,7 +45,15 @@ public:
@param a_DistanceModifier The distance modifier for affecting potency, defaults to 1 */
cEntityEffect(int a_Duration, short a_Intensity, double a_DistanceModifier = 1);
- virtual ~cEntityEffect(void);
+ /** Creates an entity effect by copying another
+ @param a_OtherEffect The other effect to copy */
+ cEntityEffect(const cEntityEffect & a_OtherEffect);
+
+ /** Creates an entity effect by copying another
+ @param a_OtherEffect The other effect to copy */
+ cEntityEffect & operator=(cEntityEffect a_OtherEffect);
+
+ virtual ~cEntityEffect(void) {};
/** Creates a pointer to the proper entity effect from the effect type
@warning This function creates raw pointers that must be manually managed.
@@ -70,8 +78,8 @@ public:
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
virtual void OnTick(cPawn & a_Target);
- virtual void OnActivate(cPawn & a_Target);
- virtual void OnDeactivate(cPawn & a_Target);
+ virtual void OnActivate(cPawn & a_Target) { }
+ virtual void OnDeactivate(cPawn & a_Target) { }
protected:
/** How many ticks this effect has been active for */
--
cgit v1.2.3
From 554e1c0dd3cedbcb4035d8ffa7351d56bee5dfb5 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 13 Jul 2014 16:10:01 -0700
Subject: OnEntityAddEffect.lua: Removed Originator param
---
MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua | 1 -
1 file changed, 1 deletion(-)
diff --git a/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua
index 423a2200b..1d1658a6f 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnEntityAddEffect.lua
@@ -18,7 +18,6 @@ return
{ Name = "EffectType", Type = "number", Notes = "The type of the effect to be added. One of the effXXX constants." },
{ Name = "EffectDuration", Type = "number", Notes = "The duration of the effect to be added, in ticks." },
{ Name = "EffectIntensity", Type = "number", Notes = "The intensity (level) of the effect to be added. " },
- { Name = "Originator", Type = "{{cEntity}}", Notes = "The entity who originated the effect (threw the potion, the cavespider that used poison bite, etc.) May be nil if there's no originator associated with the effect. " },
{ Name = "DistanceModifier", Type = "number", Notes = "The modifier for the effect intensity, based on distance. Used mainly for splash potions." },
},
Returns = [[
--
cgit v1.2.3
From 1c6c612f76d25909dd190e08dc9f32d3ab2c507a Mon Sep 17 00:00:00 2001
From: Howaner
Date: Mon, 14 Jul 2014 19:07:31 +0200
Subject: Reset meta to zero when the block explode.
---
src/ChunkMap.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 0a0a841cd..d25f6d64b 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1837,7 +1837,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
// Activate the TNT, with a random fuse between 10 to 30 game ticks
int FuseTime = 10 + m_World->GetTickRandomNumber(20);
m_World->SpawnPrimedTNT(a_BlockX + x + 0.5, a_BlockY + y + 0.5, a_BlockZ + z + 0.5, FuseTime);
- area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
+ area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
break;
}
@@ -1854,14 +1854,14 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
case E_BLOCK_STATIONARY_WATER:
{
// Turn into simulated water:
- area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_WATER);
+ area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_WATER, 0);
break;
}
case E_BLOCK_STATIONARY_LAVA:
{
// Turn into simulated lava:
- area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_LAVA);
+ area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_LAVA, 0);
break;
}
@@ -1894,7 +1894,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
m_World->SpawnFallingBlock(bx + x, by + y + 5, bz + z, Block, area.GetBlockMeta(bx + x, by + y, bz + z));
}
- area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
+ area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_AIR, 0);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
break;
--
cgit v1.2.3
From 4e24f711abd3d6a93f01ee7c297eb67c8aedbd37 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 14 Jul 2014 19:49:31 +0100
Subject: Player properties are now retrieved
---
src/ClientHandle.cpp | 7 +-
src/ClientHandle.h | 5 +-
src/Entities/Player.cpp | 4 +-
src/Protocol/Authenticator.cpp | 281 ++++++++++++++++++++++++++---------------
src/Protocol/Authenticator.h | 5 +
src/Protocol/Protocol17x.cpp | 14 +-
src/Root.cpp | 4 +-
src/Root.h | 2 +-
src/Server.cpp | 4 +-
src/Server.h | 4 +-
src/World.cpp | 2 +-
11 files changed, 216 insertions(+), 116 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 56275a9b2..fcd8d2bcd 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -290,17 +290,18 @@ void cClientHandle::Kick(const AString & a_Reason)
-void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
+void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties)
{
if (m_State != csAuthenticating)
{
return;
}
- ASSERT( m_Player == NULL );
+ ASSERT(m_Player == NULL);
m_Username = a_Name;
m_UUID = a_UUID;
+ m_Properties = a_Properties;
// Send login success (if the protocol supports it):
m_Protocol->SendLoginSuccess();
@@ -324,7 +325,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
if (!cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player))
{
cRoot::Get()->BroadcastChatJoin(Printf("%s has joined the game", GetUsername().c_str()));
- LOGINFO("Player %s has joined the game.", m_Username.c_str());
+ LOGINFO("Player %s has joined the game", m_Username.c_str());
}
m_ConfirmPosition = m_Player->GetPosition();
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index b0bbda19e..478da5b3c 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -67,6 +67,8 @@ public:
const AString & GetUUID(void) const { return m_UUID; } // tolua_export
void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; }
+
+ const AString & GetProperties(void) const { return m_Properties; }
/** Generates an UUID based on the username stored for this client, and stores it in the m_UUID member.
This is used for the offline (non-auth) mode, when there's no UUID source.
@@ -92,7 +94,7 @@ public:
static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
void Kick(const AString & a_Reason); // tolua_export
- void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication
+ void Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator when the user passes authentication
void StreamChunks(void);
@@ -280,6 +282,7 @@ private:
AString m_Username;
AString m_Password;
+ AString m_Properties;
cCriticalSection m_CSChunkLists;
cChunkCoordsList m_LoadedChunks; // Chunks that the player belongs to
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 944ed643e..6b792d766 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -130,7 +130,7 @@ cPlayer::~cPlayer(void)
if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this))
{
cRoot::Get()->BroadcastChatLeave(Printf("%s has left the game", GetName().c_str()));
- LOGINFO("Player %s has left the game.", GetName().c_str());
+ LOGINFO("Player %s has left the game", GetName().c_str());
}
LOGD("Deleting cPlayer \"%s\" at %p, ID %d", GetName().c_str(), this, GetUniqueID());
@@ -1804,7 +1804,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName)
cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
StatSerializer.Load();
- LOGD("Player \"%s\" was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
+ LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
GetName().c_str(), a_FileName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()
);
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 54b823e0f..8fd8952e8 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -11,15 +11,67 @@
#include "PolarSSL++/BlockingSslClientSocket.h"
-#include
-#include
-
#define DEFAULT_AUTH_SERVER "sessionserver.mojang.com"
#define DEFAULT_AUTH_ADDRESS "/session/minecraft/hasJoined?username=%USERNAME%&serverId=%SERVERID%"
+#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%"
+
+/** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert:
+Downloaded from http://certs.starfieldtech.com/repository/ */
+static const AString gStarfieldCACert(
+ // G2 cert
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n"
+ "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n"
+ "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n"
+ "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n"
+ "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n"
+ "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n"
+ "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n"
+ "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n"
+ "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n"
+ "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n"
+ "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n"
+ "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n"
+ "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n"
+ "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n"
+ "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n"
+ "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n"
+ "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n"
+ "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n"
+ "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n"
+ "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n"
+ "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n"
+ "-----END CERTIFICATE-----\n\n"
+ // Original (G1) cert:
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n"
+ "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n"
+ "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n"
+ "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n"
+ "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n"
+ "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n"
+ "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n"
+ "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n"
+ "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n"
+ "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n"
+ "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n"
+ "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n"
+ "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n"
+ "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n"
+ "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n"
+ "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n"
+ "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n"
+ "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n"
+ "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n"
+ "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n"
+ "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n"
+ "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n"
+ "-----END CERTIFICATE-----\n"
+);
@@ -29,6 +81,7 @@ cAuthenticator::cAuthenticator(void) :
super("cAuthenticator"),
m_Server(DEFAULT_AUTH_SERVER),
m_Address(DEFAULT_AUTH_ADDRESS),
+ m_PropertiesAddress(DEFAULT_PROPERTIES_ADDRESS),
m_ShouldAuthenticate(true)
{
}
@@ -50,6 +103,7 @@ void cAuthenticator::ReadINI(cIniFile & IniFile)
{
m_Server = IniFile.GetValueSet("Authentication", "Server", DEFAULT_AUTH_SERVER);
m_Address = IniFile.GetValueSet("Authentication", "Address", DEFAULT_AUTH_ADDRESS);
+ m_PropertiesAddress = IniFile.GetValueSet("Authentication", "PlayerPropertiesAddress", DEFAULT_PROPERTIES_ADDRESS);
m_ShouldAuthenticate = IniFile.GetValueSetB("Authentication", "Authenticate", true);
}
@@ -123,8 +177,26 @@ void cAuthenticator::Execute(void)
AString UUID;
if (AuthWithYggdrasil(NewUserName, ServerID, UUID))
{
- LOGINFO("User %s authenticated with UUID '%s'", NewUserName.c_str(), UUID.c_str());
- cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID);
+ AString Properties;
+ if (!GetPlayerProperties(UUID, Properties))
+ {
+ LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str());
+ }
+ else
+ {
+ LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str());
+ }
+
+ // If the UUID doesn't contain the hashes, insert them at the proper places:
+ if (UUID.size() == 32)
+ {
+ UUID.insert(8, "-");
+ UUID.insert(13, "-");
+ UUID.insert(18, "-");
+ UUID.insert(23, "-");
+ }
+
+ cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID, Properties);
}
else
{
@@ -137,97 +209,27 @@ void cAuthenticator::Execute(void)
-bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID)
+bool cAuthenticator::ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response)
{
- LOGD("Trying to auth user %s", a_UserName.c_str());
-
- int ret;
- unsigned char buf[1024];
-
- /* Initialize certificates */
- // This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert:
- // Downloaded from http://certs.starfieldtech.com/repository/
- static const AString StarfieldCACert(
- // G2 cert
- "-----BEGIN CERTIFICATE-----\n"
- "MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n"
- "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n"
- "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n"
- "ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n"
- "MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n"
- "b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n"
- "aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n"
- "Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n"
- "ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n"
- "nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n"
- "HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n"
- "Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n"
- "dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n"
- "HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n"
- "BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n"
- "CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n"
- "sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n"
- "4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n"
- "8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n"
- "pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n"
- "mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n"
- "-----END CERTIFICATE-----\n\n"
- // Original (G1) cert:
- "-----BEGIN CERTIFICATE-----\n"
- "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n"
- "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n"
- "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n"
- "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n"
- "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n"
- "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n"
- "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n"
- "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n"
- "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n"
- "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n"
- "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n"
- "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n"
- "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n"
- "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n"
- "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n"
- "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n"
- "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n"
- "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n"
- "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n"
- "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n"
- "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n"
- "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n"
- "-----END CERTIFICATE-----\n"
- );
-
// Connect the socket:
cBlockingSslClientSocket Socket;
- Socket.SetTrustedRootCertsFromString(StarfieldCACert, m_Server);
- if (!Socket.Connect(m_Server, 443))
+ Socket.SetTrustedRootCertsFromString(a_CACerts, a_ExpectedPeerName);
+ if (!Socket.Connect(a_ExpectedPeerName, 443))
{
- LOGWARNING("cAuthenticator: Can't connect to %s: %s", m_Server.c_str(), Socket.GetLastErrorText().c_str());
+ LOGWARNING("cAuthenticator: Can't connect to %s: %s", a_ExpectedPeerName.c_str(), Socket.GetLastErrorText().c_str());
return false;
}
- // Create the GET request:
- AString ActualAddress = m_Address;
- ReplaceString(ActualAddress, "%USERNAME%", a_UserName);
- ReplaceString(ActualAddress, "%SERVERID%", a_ServerId);
-
- AString Request;
- Request += "GET " + ActualAddress + " HTTP/1.0\r\n";
- Request += "Host: " + m_Server + "\r\n";
- Request += "User-Agent: MCServer\r\n";
- Request += "Connection: close\r\n";
- Request += "\r\n";
-
- if (!Socket.Send(Request.c_str(), Request.size()))
+ if (!Socket.Send(a_Data.c_str(), a_Data.size()))
{
LOGWARNING("cAuthenticator: Writing SSL data failed: %s", Socket.GetLastErrorText().c_str());
return false;
}
// Read the HTTP response:
- std::string Response;
+ int ret;
+ unsigned char buf[1024];
+
for (;;)
{
ret = Socket.Receive(buf, sizeof(buf));
@@ -235,7 +237,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if ((ret == POLARSSL_ERR_NET_WANT_READ) || (ret == POLARSSL_ERR_NET_WANT_WRITE))
{
// This value should never be returned, it is handled internally by cBlockingSslClientSocket
- LOGWARNING("cAuthenticator: SSL reading failed internally.");
+ LOGWARNING("cAuthenticator: SSL reading failed internally");
return false;
}
if (ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY)
@@ -252,18 +254,46 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
break;
}
- Response.append((const char *)buf, (size_t)ret);
+ a_Response.append((const char *)buf, (size_t)ret);
}
Socket.Disconnect();
+ return true;
+}
+
+
+
+
+
+bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID)
+{
+ LOGD("Trying to authenticate user %s", a_UserName.c_str());
+
+ // Create the GET request:
+ AString ActualAddress = m_Address;
+ ReplaceString(ActualAddress, "%USERNAME%", a_UserName);
+ ReplaceString(ActualAddress, "%SERVERID%", a_ServerId);
+
+ AString Request;
+ Request += "GET " + ActualAddress + " HTTP/1.0\r\n";
+ Request += "Host: " + m_Server + "\r\n";
+ Request += "User-Agent: MCServer\r\n";
+ Request += "Connection: close\r\n";
+ Request += "\r\n";
+
+ AString Response;
+ if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response))
+ {
+ return false;
+ }
// Check the HTTP status line:
- AString prefix("HTTP/1.1 200 OK");
+ const AString Prefix("HTTP/1.1 200 OK");
AString HexDump;
- if (Response.compare(0, prefix.size(), prefix))
+ if (Response.compare(0, Prefix.size(), Prefix))
{
- LOGINFO("User %s failed to auth, bad http status line received", a_UserName.c_str());
- LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ LOGINFO("User %s failed to auth, bad HTTP status line received", a_UserName.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return false;
}
@@ -271,8 +301,8 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
size_t idxHeadersEnd = Response.find("\r\n\r\n");
if (idxHeadersEnd == AString::npos)
{
- LOGINFO("User %s failed to authenticate, bad http response header received", a_UserName.c_str());
- LOG("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ LOGINFO("User %s failed to authenticate, bad HTTP response header received", a_UserName.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return false;
}
Response.erase(0, idxHeadersEnd + 4);
@@ -286,20 +316,12 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
Json::Reader reader;
if (!reader.parse(Response, root, false))
{
- LOGWARNING("cAuthenticator: Cannot parse Received Data to json!");
+ LOGWARNING("cAuthenticator: Cannot parse received data (authentication) to JSON!");
return false;
}
a_UserName = root.get("name", "Unknown").asString();
a_UUID = root.get("id", "").asString();
-
- // If the UUID doesn't contain the hashes, insert them at the proper places:
- if (a_UUID.size() == 32)
- {
- a_UUID.insert(8, "-");
- a_UUID.insert(13, "-");
- a_UUID.insert(18, "-");
- a_UUID.insert(23, "-");
- }
+
return true;
}
@@ -307,3 +329,60 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
+bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Properties)
+{
+ LOGD("Trying to get properties for user %s", a_UUID.c_str());
+
+ // Create the GET request:
+ AString ActualAddress = m_PropertiesAddress;
+ ReplaceString(ActualAddress, "%UUID%", a_UUID);
+
+ AString Request;
+ Request += "GET " + ActualAddress + " HTTP/1.0\r\n";
+ Request += "Host: " + m_Server + "\r\n";
+ Request += "User-Agent: MCServer\r\n";
+ Request += "Connection: close\r\n";
+ Request += "\r\n";
+
+ AString Response;
+ if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response))
+ {
+ return false;
+ }
+
+ // Check the HTTP status line:
+ const AString Prefix("HTTP/1.1 200 OK");
+ AString HexDump;
+ if (Response.compare(0, Prefix.size(), Prefix))
+ {
+ LOGINFO("Failed to get properties for user %s, bad HTTP status line received", a_UUID.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ return false;
+ }
+
+ // Erase the HTTP headers from the response:
+ size_t idxHeadersEnd = Response.find("\r\n\r\n");
+ if (idxHeadersEnd == AString::npos)
+ {
+ LOGINFO("Failed to get properties for user %s, bad HTTP response header received", a_UUID.c_str());
+ LOGD("Response: \n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ return false;
+ }
+ Response.erase(0, idxHeadersEnd + 4);
+
+ // Parse the Json response:
+ if (Response.empty())
+ {
+ return false;
+ }
+ Json::Value root;
+ Json::Reader reader;
+ if (!reader.parse(Response, root, false))
+ {
+ LOGWARNING("cAuthenticator: Cannot parse received properties data to JSON!");
+ return false;
+ }
+
+ a_Properties = root["properties"].toStyledString();
+ return true;
+}
\ No newline at end of file
diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h
index 211f51394..04fa3e09c 100644
--- a/src/Protocol/Authenticator.h
+++ b/src/Protocol/Authenticator.h
@@ -73,13 +73,18 @@ private:
AString m_Server;
AString m_Address;
+ AString m_PropertiesAddress;
bool m_ShouldAuthenticate;
/** cIsThread override: */
virtual void Execute(void) override;
+ bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response);
+
/** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */
bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID);
+
+ bool GetPlayerProperties(const AString & a_UUID, AString & a_Properties);
};
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 855687269..ae800e9cf 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -3015,7 +3015,19 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
Pkt.WriteVarInt(a_Player.GetUniqueID());
Pkt.WriteString(a_Player.GetClientHandle()->GetUUID());
Pkt.WriteString(a_Player.GetName());
- Pkt.WriteVarInt(0); // We have no data to send here
+
+ Json::Value root;
+ Json::Reader reader;
+ reader.parse(m_Client->GetProperties(), root);
+
+ Pkt.WriteVarInt(root.size());
+ for (Json::Value::iterator itr = root.begin(); itr != root.end(); ++itr)
+ {
+ Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString());
+ Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString());
+ Pkt.WriteString(((Json::Value)*itr).get("signature", "").toStyledString());
+ }
+
Pkt.WriteFPInt(a_Player.GetPosX());
Pkt.WriteFPInt(a_Player.GetPosY());
Pkt.WriteFPInt(a_Player.GetPosZ());
diff --git a/src/Root.cpp b/src/Root.cpp
index c82b05a66..c578fe6a3 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -499,9 +499,9 @@ void cRoot::KickUser(int a_ClientID, const AString & a_Reason)
-void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID)
+void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties)
{
- m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID);
+ m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID, a_Properties);
}
diff --git a/src/Root.h b/src/Root.h
index d2a4d1eed..a9e985656 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -89,7 +89,7 @@ public:
void KickUser(int a_ClientID, const AString & a_Reason);
/// Called by cAuthenticator to auth the specified user
- void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID);
+ void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties = "");
/// Executes commands queued in the command queue
void TickCommands(void);
diff --git a/src/Server.cpp b/src/Server.cpp
index 9220731eb..8b479292e 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -656,14 +656,14 @@ void cServer::KickUser(int a_ClientID, const AString & a_Reason)
-void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID)
+void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties)
{
cCSLock Lock(m_CSClients);
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
{
if ((*itr)->GetUniqueID() == a_ClientID)
{
- (*itr)->Authenticate(a_Name, a_UUID);
+ (*itr)->Authenticate(a_Name, a_UUID, a_Properties);
return;
}
} // for itr - m_Clients[]
diff --git a/src/Server.h b/src/Server.h
index 5227799e8..672dc26c0 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -37,7 +37,7 @@
class cPlayer;
class cClientHandle;
class cIniFile;
-class cCommandOutputCallback ;
+class cCommandOutputCallback;
typedef std::list cClientHandleList;
@@ -83,7 +83,7 @@ public: // tolua_export
void Shutdown(void);
void KickUser(int a_ClientID, const AString & a_Reason);
- void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator to auth the specified user
+ void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator to auth the specified user
const AString & GetServerID(void) const { return m_ServerID; } // tolua_export
diff --git a/src/World.cpp b/src/World.cpp
index 64a629233..3c0db6da9 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2363,7 +2363,7 @@ void cWorld::RemovePlayer(cPlayer * a_Player)
}
{
cCSLock Lock(m_CSPlayers);
- LOGD("Removing player \"%s\" from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str());
+ LOGD("Removing player %s from world \"%s\"", a_Player->GetName().c_str(), m_WorldName.c_str());
m_Players.remove(a_Player);
}
--
cgit v1.2.3
From 1929d16724de6f451c9485076b4091cbc457916c Mon Sep 17 00:00:00 2001
From: Tycho
Date: Mon, 14 Jul 2014 20:26:36 +0100
Subject: Added first implementation of cClearMetaOnDrop
---
src/Blocks/BlockLadder.h | 5 +++--
src/Blocks/ClearMetaOnDrop.h | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
create mode 100644 src/Blocks/ClearMetaOnDrop.h
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index a605edf3f..1af2be067 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -3,17 +3,18 @@
#include "BlockHandler.h"
#include "../World.h"
+#include "ClearMetaOnDrop.h"
class cBlockLadderHandler :
- public cMetaRotator
+ public cClearMetaOnDrop >
{
public:
cBlockLadderHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator(a_BlockType)
+ : cClearMetaOnDrop >(a_BlockType)
{
}
diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h
new file mode 100644
index 000000000..21b987f2c
--- /dev/null
+++ b/src/Blocks/ClearMetaOnDrop.h
@@ -0,0 +1,18 @@
+
+#pragma once
+
+template
+class cClearMetaOnDrop : public Base
+{
+public:
+
+ cClearMetaOnDrop(BLOCKTYPE a_BlockType) :
+ Base(a_BlockType)
+ {}
+
+ virtual ~cClearMetaOnDrop() {}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(this->m_BlockType, 1, 0));
+ }
+};
--
cgit v1.2.3
From 515c3cbc67816fb770ff7e32bd593bd55c26788c Mon Sep 17 00:00:00 2001
From: Tycho
Date: Mon, 14 Jul 2014 20:28:16 +0100
Subject: Added cClearOnDrop Mixin to cPumpkin
---
src/Blocks/BlockPumpkin.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h
index ac2b9817a..f4022735b 100644
--- a/src/Blocks/BlockPumpkin.h
+++ b/src/Blocks/BlockPumpkin.h
@@ -6,11 +6,11 @@
class cBlockPumpkinHandler :
- public cMetaRotator
+ public cClearMetaOnDrop >
{
public:
cBlockPumpkinHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator(a_BlockType)
+ : cClearMetaOnDrop >(a_BlockType)
{
}
--
cgit v1.2.3
From 093b5c6456fd2c635441630c87853a3a00008af8 Mon Sep 17 00:00:00 2001
From: Tycho
Date: Mon, 14 Jul 2014 20:33:30 +0100
Subject: Simplified ClearMetaOnDrop
---
src/Blocks/ClearMetaOnDrop.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h
index 21b987f2c..e6d26863a 100644
--- a/src/Blocks/ClearMetaOnDrop.h
+++ b/src/Blocks/ClearMetaOnDrop.h
@@ -13,6 +13,6 @@ public:
virtual ~cClearMetaOnDrop() {}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(this->m_BlockType, 1, 0));
+ a_Pickups.push_back(cItem(this->m_BlockType));
}
};
--
cgit v1.2.3
From 333f4f982cbd24ffcb376594eddef439b3f05e9e Mon Sep 17 00:00:00 2001
From: Tycho
Date: Mon, 14 Jul 2014 20:50:56 +0100
Subject: Converted some blockhandlers to use cClearMetaOnDrop
---
src/Blocks/BlockBrewingStand.h | 10 +++-------
src/Blocks/BlockCobWeb.h | 10 ++--------
src/Blocks/BlockFlowerPot.h | 9 ++-------
src/Blocks/BlockLilypad.h | 9 ++-------
src/Blocks/BlockMycelium.h | 8 ++------
src/Blocks/BlockRedstone.h | 11 ++---------
src/Blocks/BlockRedstoneLamp.h | 9 ++-------
src/Blocks/BlockRedstoneRepeater.h | 13 +++----------
src/Blocks/BlockStone.h | 9 +++------
9 files changed, 21 insertions(+), 67 deletions(-)
diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h
index 57642bcb6..77e383b16 100644
--- a/src/Blocks/BlockBrewingStand.h
+++ b/src/Blocks/BlockBrewingStand.h
@@ -2,25 +2,21 @@
#pragma once
#include "BlockHandler.h"
+#include "ClearMetaOnDrop.h"
class cBlockBrewingStandHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockBrewingStandHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_BREWING_STAND, 1, 0));
- }
-
virtual bool IsUseable() override
{
return true;
diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h
index 982bfaa30..29a6b8155 100644
--- a/src/Blocks/BlockCobWeb.h
+++ b/src/Blocks/BlockCobWeb.h
@@ -10,19 +10,13 @@
class cBlockCobWebHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockCobWebHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
- }
} ;
diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h
index fc75ef638..39fbe1bd9 100644
--- a/src/Blocks/BlockFlowerPot.h
+++ b/src/Blocks/BlockFlowerPot.h
@@ -9,18 +9,13 @@
class cBlockFlowerPotHandler :
- public cBlockEntityHandler
+ public cClearMetaOnDrop
{
public:
cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) :
- cBlockEntityHandler(a_BlockType)
+ cClearMetaOnDrop(a_BlockType)
{
}
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
- }
} ;
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index 2dd4ec768..fc37f360c 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -8,19 +8,14 @@
class cBlockLilypadHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockLilypadHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to zero
- a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0));
- }
};
diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h
index 2a8ef5fca..4d4a0bb4f 100644
--- a/src/Blocks/BlockMycelium.h
+++ b/src/Blocks/BlockMycelium.h
@@ -8,20 +8,16 @@
class cBlockMyceliumHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockMyceliumHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
// TODO: Add Mycel Spread
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
- }
virtual const char * GetStepSound(void) override
{
diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h
index a898c9acb..6dbf46a57 100644
--- a/src/Blocks/BlockRedstone.h
+++ b/src/Blocks/BlockRedstone.h
@@ -9,11 +9,11 @@
class cBlockRedstoneHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
@@ -22,13 +22,6 @@ public:
{
return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
}
-
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to 0
- a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1));
- }
} ;
diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h
index 69a2b27c2..4b0ca5b34 100644
--- a/src/Blocks/BlockRedstoneLamp.h
+++ b/src/Blocks/BlockRedstoneLamp.h
@@ -8,18 +8,13 @@
class cBlockRedstoneLampHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockRedstoneLampHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));
- }
};
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index fe6cd21b9..1e9c00f2e 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -4,16 +4,16 @@
#include "BlockHandler.h"
#include "Chunk.h"
#include "MetaRotator.h"
-
+#include "ClearMetaOnDrop.h"
class cBlockRedstoneRepeaterHandler :
- public cMetaRotator
+ public cClearMetaOnDrop >
{
public:
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
- : cMetaRotator(a_BlockType)
+ : cClearMetaOnDrop >(a_BlockType)
{
}
@@ -44,13 +44,6 @@ public:
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to 0
- a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0));
- }
-
-
virtual bool IsUseable(void) override
{
return true;
diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h
index cd5230f49..697ab0312 100644
--- a/src/Blocks/BlockStone.h
+++ b/src/Blocks/BlockStone.h
@@ -2,24 +2,21 @@
#pragma once
#include "BlockHandler.h"
+#include "ClearMetaOnDrop.h"
class cBlockStoneHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockStoneHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_COBBLESTONE, 1, 0));
- }
} ;
--
cgit v1.2.3
From 2cd3443fbbb498f06227ed44db0c6a749cafdb76 Mon Sep 17 00:00:00 2001
From: Tycho
Date: Mon, 14 Jul 2014 21:21:17 +0100
Subject: Added documentation
---
src/Blocks/ClearMetaOnDrop.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h
index e6d26863a..3f8c33819 100644
--- a/src/Blocks/ClearMetaOnDrop.h
+++ b/src/Blocks/ClearMetaOnDrop.h
@@ -1,6 +1,12 @@
#pragma once
+// mixin for use to clear meta values when the block is converted to a pickup
+
+// Usage: inherit from this class, passing the parent class as the parameter Base
+// For example to use in class Foo which should inherit Bar use
+// class Foo : public cClearMetaOnDrop;
+
template
class cClearMetaOnDrop : public Base
{
--
cgit v1.2.3
From 061010288a99fd11f91bf713ac68068c57f79be7 Mon Sep 17 00:00:00 2001
From: archshift
Date: Mon, 14 Jul 2014 13:46:15 -0700
Subject: Readability and clarity changes
---
src/Entities/Entity.cpp | 9 ++++--
src/Entities/EntityEffect.cpp | 41 +++++++++--------------
src/Entities/EntityEffect.h | 2 +-
src/Items/ItemPotion.h | 75 ++++++++++++++++++++++++++-----------------
4 files changed, 68 insertions(+), 59 deletions(-)
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 042c4b4c3..670e8420a 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -311,10 +311,13 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// IsOnGround() only is false if the player is moving downwards
// TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain)
- if (!Player->IsOnGround() && (a_TDI.DamageType == dtAttack || a_TDI.DamageType == dtArrowAttack))
+ if (!Player->IsOnGround())
{
- a_TDI.FinalDamage += 2;
- m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
+ if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack))
+ {
+ a_TDI.FinalDamage += 2;
+ m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
+ }
}
Player->GetStatManager().AddValue(statDamageDealt, (StatValue)floor(a_TDI.FinalDamage * 10 + 0.5));
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 852099b79..12dd17d72 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -113,15 +113,12 @@ void cEntityEffect::OnTick(cPawn & a_Target)
void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
- int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier);
+ int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier);
- if (a_Target.IsMob())
+ if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
{
- if (((cMonster &) a_Target).IsUndead())
- {
- a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
- return;
- }
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+ return;
}
a_Target.Heal(amount);
}
@@ -136,15 +133,12 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
- int amount = (int)(6 * std::pow(2.0, m_Intensity) * m_DistanceModifier);
+ int amount = (int)(6 * (1 << m_Intensity) * m_DistanceModifier);
- if (a_Target.IsMob())
+ if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
{
- if (((cMonster &) a_Target).IsUndead())
- {
- a_Target.Heal(amount);
- return;
- }
+ a_Target.Heal(amount);
+ return;
}
a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
}
@@ -160,18 +154,15 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
- if (a_Target.IsMob())
+ if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
{
- if (((cMonster &) a_Target).IsUndead())
- {
- return;
- }
+ return;
}
// Regen frequency = 50 ticks, divided by potion level (Regen II = 25 ticks)
int frequency = (int) std::floor(50.0 / (double)(m_Intensity + 1));
- if (m_Ticks % frequency != 0)
+ if ((m_Ticks % frequency) != 0)
{
return;
}
@@ -231,9 +222,9 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
cMonster & Target = (cMonster &) a_Target;
// Doesn't effect undead mobs, spiders
- if (Target.IsUndead()
- || Target.GetMobType() == cMonster::mtSpider
- || Target.GetMobType() == cMonster::mtCaveSpider)
+ if ((Target.IsUndead())
+ || (Target.GetMobType() == cMonster::mtSpider)
+ || (Target.GetMobType() == cMonster::mtCaveSpider))
{
return;
}
@@ -242,7 +233,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
// Poison frequency = 25 ticks, divided by potion level (Poison II = 12 ticks)
int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
- if (m_Ticks % frequency == 0)
+ if ((m_Ticks % frequency) == 0)
{
// Cannot take poison damage when health is at 1
if (a_Target.GetHealth() > 1)
@@ -266,7 +257,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
// Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
- if (m_Ticks % frequency == 0)
+ if ((m_Ticks % frequency) == 0)
{
a_Target.TakeDamage(dtWither, NULL, 1, 0);
}
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index c6532a9bd..ea0716d59 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -220,7 +220,7 @@ class cEntityEffectNausea:
typedef cEntityEffect super;
public:
cEntityEffectNausea(int a_Duration, short a_Intensity, double a_DistanceModifier = 1):
- super(a_Duration, a_Intensity, a_DistanceModifier)
+ super(a_Duration, a_Intensity, a_DistanceModifier)
{
}
};
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 5badeda94..b72499431 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -11,33 +11,35 @@ class cItemPotionHandler:
int GetPotionName(short a_ItemDamage)
{
- return a_ItemDamage & 63;
+ // First six bits (least significant)
+ return a_ItemDamage & 0x3F;
}
cEntityEffect::eType GetEntityEffectType(short a_ItemDamage)
{
+ // First four bits (least significant)
// Potion effect bits are different from entity effect values
// For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits
- switch (a_ItemDamage & 15)
+ switch (a_ItemDamage & 0xF)
{
- case 1: return cEntityEffect::effRegeneration;
- case 2: return cEntityEffect::effSpeed;
- case 3: return cEntityEffect::effFireResistance;
- case 4: return cEntityEffect::effPoison;
- case 5: return cEntityEffect::effInstantHealth;
- case 6: return cEntityEffect::effNightVision;
- case 8: return cEntityEffect::effWeakness;
- case 9: return cEntityEffect::effStrength;
- case 10: return cEntityEffect::effSlowness;
- case 12: return cEntityEffect::effInstantDamage;
- case 13: return cEntityEffect::effWaterBreathing;
- case 14: return cEntityEffect::effInvisibility;
+ case 0x1: return cEntityEffect::effRegeneration;
+ case 0x2: return cEntityEffect::effSpeed;
+ case 0x3: return cEntityEffect::effFireResistance;
+ case 0x4: return cEntityEffect::effPoison;
+ case 0x5: return cEntityEffect::effInstantHealth;
+ case 0x6: return cEntityEffect::effNightVision;
+ case 0x8: return cEntityEffect::effWeakness;
+ case 0x9: return cEntityEffect::effStrength;
+ case 0xA: return cEntityEffect::effSlowness;
+ case 0xC: return cEntityEffect::effInstantDamage;
+ case 0xD: return cEntityEffect::effWaterBreathing;
+ case 0xE: return cEntityEffect::effInvisibility;
// No effect potions
- case 0:
- case 7:
- case 11:
- case 15:
+ case 0x0:
+ case 0x7:
+ case 0xB: // Will be potion of leaping in 1.8
+ case 0xF:
{
break;
}
@@ -48,9 +50,8 @@ class cItemPotionHandler:
short GetEntityEffectIntensity(short a_ItemDamage)
{
- // Level II potion if fifth bit is set
- if (a_ItemDamage & 32) return 1;
- else return 0;
+ // Level II potion if fifth bit (from zero) is set
+ return (a_ItemDamage & 0x20) ? 1 : 0;
}
int GetEntityEffectDuration(short a_ItemDamage)
@@ -91,8 +92,8 @@ class cItemPotionHandler:
TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1;
// If potion is extended, multiply duration by 8/3. If not, stays the same
- // Extended potion if sixth bit is set
- ExtCoeff = (a_ItemDamage & 64) ? (8.0/3.0) : 1;
+ // Extended potion if sixth bit (from zero) is set
+ ExtCoeff = (a_ItemDamage & 0x40) ? (8.0/3.0) : 1;
// If potion is splash potion, multiply duration by 3/4. If not, stays the same
SplashCoeff = IsDrinkable(a_ItemDamage) ? 1 : 0.75;
@@ -112,18 +113,26 @@ public:
virtual bool IsDrinkable(short a_ItemDamage) override
{
- // Drinkable potion if 13th bit is set
+ // Drinkable potion if 13th bit (from zero) is set
// For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
- return ((a_ItemDamage & 8192) != 0);
+ return ((a_ItemDamage & 0x2000) != 0);
}
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
{
+ short PotionDamage = a_Item.m_ItemDamage;
+
+ // Only called when potion is a splash potion
+ if (IsDrinkable(PotionDamage))
+ {
+ return false;
+ }
+
Vector3d Pos = a_Player->GetThrowStartPos();
Vector3d Speed = a_Player->GetLookVector() * 7;
- short potion_damage = a_Item.m_ItemDamage;
- cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(potion_damage), cEntityEffect(GetEntityEffectDuration(potion_damage), GetEntityEffectIntensity(potion_damage)), GetPotionName(potion_damage));
+ cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage)), GetPotionName(PotionDamage));
+
if (Projectile == NULL)
{
return false;
@@ -139,14 +148,20 @@ public:
a_Player->GetInventory().RemoveOneEquippedItem();
}
- // Called when potion is a splash potion
return true;
}
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
- // Called when potion is a drinkable potion
- a_Player->AddEntityEffect(GetEntityEffectType(a_Item->m_ItemDamage), GetEntityEffectDuration(a_Item->m_ItemDamage), GetEntityEffectIntensity(a_Item->m_ItemDamage));
+ short PotionDamage = a_Item->m_ItemDamage;
+
+ // Only called when potion is a drinkable potion
+ if (!IsDrinkable(a_Item->m_ItemDamage))
+ {
+ return false;
+ }
+
+ a_Player->AddEntityEffect(GetEntityEffectType(PotionDamage), GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage));
a_Player->GetInventory().RemoveOneEquippedItem();
a_Player->GetInventory().AddItem(E_ITEM_GLASS_BOTTLE);
return true;
--
cgit v1.2.3
From 40bb98510a820469184e4947db3de22088b55fc7 Mon Sep 17 00:00:00 2001
From: archshift
Date: Sun, 13 Jul 2014 16:54:42 -0700
Subject: ItemHandler.cpp: removed redundant food and drink checks
---
src/Items/ItemHandler.cpp | 33 ---------------------------------
1 file changed, 33 deletions(-)
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 7fae2d395..85406c826 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -474,32 +474,6 @@ bool cItemHandler::IsTool()
bool cItemHandler::IsFood(void)
{
- switch (m_ItemType)
- {
- case E_ITEM_RED_APPLE:
- case E_ITEM_GOLDEN_APPLE:
- case E_ITEM_MUSHROOM_SOUP:
- case E_ITEM_BREAD:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_RAW_FISH:
- case E_ITEM_COOKED_FISH:
- case E_ITEM_COOKIE:
- case E_ITEM_MELON_SLICE:
- case E_ITEM_RAW_BEEF:
- case E_ITEM_STEAK:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_SPIDER_EYE:
- case E_ITEM_CARROT:
- case E_ITEM_POTATO:
- case E_ITEM_BAKED_POTATO:
- case E_ITEM_POISONOUS_POTATO:
- {
- return true;
- }
- } // switch (m_ItemType)
return false;
}
@@ -511,13 +485,6 @@ bool cItemHandler::IsDrinkable(short a_ItemDamage)
{
UNUSED(a_ItemDamage);
- switch (m_ItemType)
- {
- case E_ITEM_MILK:
- {
- return true;
- }
- } // switch (m_ItemType)
return false;
}
--
cgit v1.2.3
From f0187cc8f9922093b1e83687f869b813a8e90930 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 14 Jul 2014 21:55:46 +0100
Subject: Fixed placing liquids over liquids
* Fixes #1182
---
src/Items/ItemBucket.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 5529b4e36..84835c021 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -203,7 +203,7 @@ public:
if (a_BlockType != E_BLOCK_AIR)
{
m_ReplacedBlock = a_BlockType;
- if (!cFluidSimulator::CanWashAway(a_BlockType))
+ if (!cFluidSimulator::CanWashAway(a_BlockType) && !IsBlockLiquid(a_BlockType))
{
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, (eBlockFace)a_EntryFace); // Was an unwashawayable block, can't overwrite it!
}
--
cgit v1.2.3
From ad6494fb36b1bb19f39796ad9d5ce4544a21f361 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 14 Jul 2014 21:56:40 +0100
Subject: Maybe improved arrow sinking
---
src/Entities/ArrowEntity.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index d5e41bd46..a3a1667e4 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -79,8 +79,8 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
}
Vector3d Hit = a_HitPos;
- Vector3d SinkMovement = (GetSpeed() / 800);
- Hit += (SinkMovement * 0.01) / SinkMovement.Length(); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside)
+ Vector3d SinkMovement = (GetSpeed() / 1000);
+ Hit += SinkMovement * (0.0005 / SinkMovement.Length()); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside)
super::OnHitSolidBlock(Hit, a_HitFace);
Vector3i BlockHit = Hit.Floor();
--
cgit v1.2.3
From 5b1552435f95887ba59c707e3635dcaf9cb358f4 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 14 Jul 2014 21:57:44 +0100
Subject: Fixed some meta resetting bugs
* Fixes #1174
* Fixes #1171
---
src/Blocks/BlockCloth.h | 7 -------
src/Blocks/BlockFarmland.h | 11 +++++++----
src/Blocks/BlockHandler.cpp | 2 +-
src/Blocks/BlockHayBale.h | 1 -
src/Blocks/BlockLadder.h | 22 ++++++++++++++--------
src/Blocks/BlockSideways.h | 12 ++++++------
6 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h
index a136d3b9d..3c1ae7c25 100644
--- a/src/Blocks/BlockCloth.h
+++ b/src/Blocks/BlockCloth.h
@@ -16,13 +16,6 @@ public:
{
}
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- a_Pickups.push_back(cItem(E_BLOCK_WOOL, 1, a_BlockMeta));
- }
-
-
virtual const char * GetStepSound(void) override
{
return "step.cloth";
diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h
index 3dd5bcd1d..390b6e5ee 100644
--- a/src/Blocks/BlockFarmland.h
+++ b/src/Blocks/BlockFarmland.h
@@ -19,15 +19,13 @@
class cBlockFarmlandHandler :
public cBlockHandler
{
- typedef cBlockHandler super;
public:
- cBlockFarmlandHandler(void) :
- super(E_BLOCK_FARMLAND)
+ cBlockFarmlandHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
{
}
-
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
bool Found = false;
@@ -105,6 +103,11 @@ public:
}
}
}
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta
+ }
} ;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 730774ab1..cef1f5f09 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -211,7 +211,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
- case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( );
+ case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType);
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
diff --git a/src/Blocks/BlockHayBale.h b/src/Blocks/BlockHayBale.h
index 5b646e264..3c6472adb 100644
--- a/src/Blocks/BlockHayBale.h
+++ b/src/Blocks/BlockHayBale.h
@@ -1,7 +1,6 @@
#pragma once
-#include "BlockHandler.h"
#include "BlockSideways.h"
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index a605edf3f..7efd8e444 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -41,21 +41,27 @@ public:
}
- static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) // tolua_export
- { // tolua_export
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.Add(m_BlockType, 1, 0); // Reset meta
+ }
+
+
+ static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
+ {
switch (a_Direction)
{
case BLOCK_FACE_ZM: return 0x2;
case BLOCK_FACE_ZP: return 0x3;
case BLOCK_FACE_XM: return 0x4;
case BLOCK_FACE_XP: return 0x5;
- default: return 0x2;
+ default: return 0x2;
}
- } // tolua_export
+ }
- static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
- { // tolua_export
+ static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
+ {
switch (a_MetaData)
{
case 0x2: return BLOCK_FACE_ZM;
@@ -64,10 +70,10 @@ public:
case 0x5: return BLOCK_FACE_XP;
default: return BLOCK_FACE_ZM;
}
- } // tolua_export
+ }
- /// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure
+ /** Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure */
static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
for (int FaceInt = BLOCK_FACE_ZM; FaceInt <= BLOCK_FACE_XP; FaceInt++)
diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h
index d67c3aa24..5b37efd75 100644
--- a/src/Blocks/BlockSideways.h
+++ b/src/Blocks/BlockSideways.h
@@ -32,36 +32,36 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3);
+ a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta
}
- inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_WoodMeta)
+ inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_Meta)
{
switch (a_BlockFace)
{
case BLOCK_FACE_YM:
case BLOCK_FACE_YP:
{
- return a_WoodMeta; // Top or bottom, just return original
+ return a_Meta; // Top or bottom, just return original
}
case BLOCK_FACE_ZP:
case BLOCK_FACE_ZM:
{
- return a_WoodMeta | 0x8; // North or south
+ return a_Meta | 0x8; // North or south
}
case BLOCK_FACE_XP:
case BLOCK_FACE_XM:
{
- return a_WoodMeta | 0x4; // East or west
+ return a_Meta | 0x4; // East or west
}
default:
{
ASSERT(!"Unhandled block face!");
- return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark)
+ return a_Meta | 0xC; // No idea, give a special meta
}
}
}
--
cgit v1.2.3
From 82fe5c05f0456a11fcb2079eaf44ee0565b0c3c7 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Mon, 14 Jul 2014 23:03:30 +0100
Subject: Fixed redstone simulator crash
* Fixes #1176
* Fixed #1186
---
src/Simulator/IncrementalRedstoneSimulator.cpp | 35 +++++++++++++++++++++-----
src/Simulator/IncrementalRedstoneSimulator.h | 4 +--
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 8b9d830cd..fb5b01e17 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -396,7 +396,13 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R
int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ;
AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on
- if (AreCoordsDirectlyPowered(X, Y, Z))
+ cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z);
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
+ {
+ return;
+ }
+
+ if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour))
{
// There was a match, torch goes off
m_Chunk->SetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ));
@@ -445,9 +451,15 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R
// Check if the block the torch is on is powered
int X = a_RelBlockX; int Y = a_RelBlockY; int Z = a_RelBlockZ;
AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on
-
+
+ cChunk * Neighbour = m_Chunk->GetRelNeighborChunk(X, Z);
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
+ {
+ return;
+ }
+
// See if off state torch can be turned on again
- if (AreCoordsDirectlyPowered(X, Y, Z))
+ if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour))
{
return; // Something matches, torch still powered
}
@@ -1492,13 +1504,14 @@ void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlo
-bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
+bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk)
{
+ // Torches want to access neighbour's data when on a wall, hence the extra chunk parameter
+
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
- PoweredBlocksList * Powered = m_Chunk->GetNeighborChunk(BlockX, BlockZ)->GetRedstoneSimulatorPoweredBlocksList(); // Torches want to access neighbour's data when on a wall
- for (PoweredBlocksList::const_iterator itr = Powered->begin(); itr != Powered->end(); ++itr) // Check powered list
+ for (PoweredBlocksList::const_iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end(); ++itr) // Check powered list
{
if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
@@ -1900,6 +1913,11 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl
int SourceZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelSourceZ;
cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
+ {
+ return;
+ }
+
PoweredBlocksList * Powered = Neighbour->GetRedstoneSimulatorPoweredBlocksList(); // We need to insert the value into the chunk who owns the block position
for (PoweredBlocksList::iterator itr = Powered->begin(); itr != Powered->end(); ++itr)
{
@@ -1977,6 +1995,11 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered(
}
cChunk * Neighbour = m_Chunk->GetNeighborChunk(BlockX, BlockZ);
+ if ((Neighbour == NULL) || !Neighbour->IsValid())
+ {
+ return;
+ }
+
LinkedBlocksList * Linked = Neighbour->GetRedstoneSimulatorLinkedBlocksList();
for (LinkedBlocksList::iterator itr = Linked->begin(); itr != Linked->end(); ++itr) // Check linked powered list
{
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index ce987a60f..1faf4187b 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -162,9 +162,9 @@ private:
void SetSourceUnpowered(int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, cChunk * a_Chunk, bool a_IsFirstCall = true);
/** Returns if a coordinate is powered or linked powered */
- bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); }
+ bool AreCoordsPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { return AreCoordsDirectlyPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk) || AreCoordsLinkedPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); }
/** Returns if a coordinate is in the directly powered blocks list */
- bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
+ bool AreCoordsDirectlyPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, cChunk * a_Chunk);
/** Returns if a coordinate is in the indirectly powered blocks list */
bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */
--
cgit v1.2.3
From 8fd636aa7235698263e3b85388a4f6373cbedb76 Mon Sep 17 00:00:00 2001
From: Tycho
Date: Mon, 14 Jul 2014 23:59:24 +0100
Subject: Revert "Converted some blockhandlers to use cClearMetaOnDrop"
This reverts commit 333f4f982cbd24ffcb376594eddef439b3f05e9e.
---
src/Blocks/BlockBrewingStand.h | 10 +++++++---
src/Blocks/BlockCobWeb.h | 10 ++++++++--
src/Blocks/BlockFlowerPot.h | 9 +++++++--
src/Blocks/BlockLilypad.h | 9 +++++++--
src/Blocks/BlockMycelium.h | 8 ++++++--
src/Blocks/BlockRedstone.h | 11 +++++++++--
src/Blocks/BlockRedstoneLamp.h | 9 +++++++--
src/Blocks/BlockRedstoneRepeater.h | 13 ++++++++++---
src/Blocks/BlockStone.h | 9 ++++++---
9 files changed, 67 insertions(+), 21 deletions(-)
diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h
index 77e383b16..57642bcb6 100644
--- a/src/Blocks/BlockBrewingStand.h
+++ b/src/Blocks/BlockBrewingStand.h
@@ -2,21 +2,25 @@
#pragma once
#include "BlockHandler.h"
-#include "ClearMetaOnDrop.h"
class cBlockBrewingStandHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockBrewingStandHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_BREWING_STAND, 1, 0));
+ }
+
virtual bool IsUseable() override
{
return true;
diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h
index 29a6b8155..982bfaa30 100644
--- a/src/Blocks/BlockCobWeb.h
+++ b/src/Blocks/BlockCobWeb.h
@@ -10,13 +10,19 @@
class cBlockCobWebHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockCobWebHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
+ }
} ;
diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h
index 39fbe1bd9..fc75ef638 100644
--- a/src/Blocks/BlockFlowerPot.h
+++ b/src/Blocks/BlockFlowerPot.h
@@ -9,13 +9,18 @@
class cBlockFlowerPotHandler :
- public cClearMetaOnDrop
+ public cBlockEntityHandler
{
public:
cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) :
- cClearMetaOnDrop(a_BlockType)
+ cBlockEntityHandler(a_BlockType)
{
}
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
+ }
} ;
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index fc37f360c..2dd4ec768 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -8,14 +8,19 @@
class cBlockLilypadHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockLilypadHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to zero
+ a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0));
+ }
};
diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h
index 4d4a0bb4f..2a8ef5fca 100644
--- a/src/Blocks/BlockMycelium.h
+++ b/src/Blocks/BlockMycelium.h
@@ -8,16 +8,20 @@
class cBlockMyceliumHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockMyceliumHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
// TODO: Add Mycel Spread
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
+ }
virtual const char * GetStepSound(void) override
{
diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h
index 6dbf46a57..a898c9acb 100644
--- a/src/Blocks/BlockRedstone.h
+++ b/src/Blocks/BlockRedstone.h
@@ -9,11 +9,11 @@
class cBlockRedstoneHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
@@ -22,6 +22,13 @@ public:
{
return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
}
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1));
+ }
} ;
diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h
index 4b0ca5b34..69a2b27c2 100644
--- a/src/Blocks/BlockRedstoneLamp.h
+++ b/src/Blocks/BlockRedstoneLamp.h
@@ -8,13 +8,18 @@
class cBlockRedstoneLampHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockRedstoneLampHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));
+ }
};
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index 1e9c00f2e..fe6cd21b9 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -4,16 +4,16 @@
#include "BlockHandler.h"
#include "Chunk.h"
#include "MetaRotator.h"
-#include "ClearMetaOnDrop.h"
+
class cBlockRedstoneRepeaterHandler :
- public cClearMetaOnDrop >
+ public cMetaRotator
{
public:
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop >(a_BlockType)
+ : cMetaRotator(a_BlockType)
{
}
@@ -44,6 +44,13 @@ public:
}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Reset meta to 0
+ a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0));
+ }
+
+
virtual bool IsUseable(void) override
{
return true;
diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h
index 697ab0312..cd5230f49 100644
--- a/src/Blocks/BlockStone.h
+++ b/src/Blocks/BlockStone.h
@@ -2,21 +2,24 @@
#pragma once
#include "BlockHandler.h"
-#include "ClearMetaOnDrop.h"
class cBlockStoneHandler :
- public cClearMetaOnDrop
+ public cBlockHandler
{
public:
cBlockStoneHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : cBlockHandler(a_BlockType)
{
}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_BLOCK_COBBLESTONE, 1, 0));
+ }
} ;
--
cgit v1.2.3
From 0e5fa2662aa2b559335a25ee78cd086f795be79e Mon Sep 17 00:00:00 2001
From: Tycho
Date: Tue, 15 Jul 2014 00:01:16 +0100
Subject: COnverted Lilypad back to mixin
---
src/Blocks/BlockLilypad.h | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index 2dd4ec768..c25f150c7 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -8,19 +8,13 @@
class cBlockLilypadHandler :
- public cBlockHandler
+ public cClearMetaOnDrop
{
public:
cBlockLilypadHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : cClearMetaOnDrop(a_BlockType)
{
}
-
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Reset meta to zero
- a_Pickups.push_back(cItem(E_BLOCK_LILY_PAD, 1, 0));
- }
};
--
cgit v1.2.3
From 7195c7dfe2d0cc927c2a065662eba9be99817f70 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 08:28:10 +0200
Subject: Added missing member initialization to cGridStructGen.
Fixes CID 68228.
---
src/Generating/GridStructGen.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp
index a3578de6f..fd1d5e49f 100644
--- a/src/Generating/GridStructGen.cpp
+++ b/src/Generating/GridStructGen.cpp
@@ -44,6 +44,7 @@ cGridStructGen::cGridStructGen(
int a_MaxStructureSizeX, int a_MaxStructureSizeZ,
size_t a_MaxCacheSize
) :
+ m_Seed(a_Seed),
m_Noise(a_Seed),
m_GridSizeX(a_GridSizeX),
m_GridSizeZ(a_GridSizeZ),
--
cgit v1.2.3
From e2a1118f88a32bd2912fc8abc81db0dacbb42531 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 08:48:12 +0200
Subject: Pass cItem by reference.
Fixes CID 66445.
---
src/BlockEntities/FlowerPotEntity.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h
index da3fe9b7e..e3570eb9a 100644
--- a/src/BlockEntities/FlowerPotEntity.h
+++ b/src/BlockEntities/FlowerPotEntity.h
@@ -53,7 +53,7 @@ public:
cItem GetItem(void) const { return m_Item; }
/** Set the item in the flower pot */
- void SetItem(const cItem a_Item) { m_Item = a_Item; }
+ void SetItem(const cItem & a_Item) { m_Item = a_Item; }
// tolua_end
--
cgit v1.2.3
From d27485157847325c82fb93448f4ad05407abbd58 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 09:43:45 +0200
Subject: Fixed a MSVC warning in cEntityEffect::CreateEntityEffect().
---
src/Entities/EntityEffect.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 12dd17d72..d1f3e9026 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -91,6 +91,7 @@ cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectT
}
ASSERT(!"Unhandled entity effect type!");
+ return NULL;
}
--
cgit v1.2.3
From 5193335efa1c0da08713715844801ee589dcfdf5 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 09:48:11 +0200
Subject: Reformatted EntityEffect code.
---
src/Entities/EntityEffect.cpp | 54 +++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 25 deletions(-)
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index d1f3e9026..761a4d651 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -109,8 +109,8 @@ void cEntityEffect::OnTick(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Instant Health
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectInstantHealth:
+
void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
@@ -118,7 +118,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
{
- a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
return;
}
a_Target.Heal(amount);
@@ -129,8 +129,8 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Instant Damage
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectInstantDamage:
+
void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
{
// Base amount = 6, doubles for every increase in intensity
@@ -141,7 +141,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
a_Target.Heal(amount);
return;
}
- a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+ a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
}
@@ -149,8 +149,8 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Regeneration
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectRegeneration:
+
void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -176,8 +176,8 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Hunger
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectHunger:
+
void cEntityEffectHunger::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -185,7 +185,7 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target)
if (a_Target.IsPlayer())
{
cPlayer & Target = (cPlayer &) a_Target;
- Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick
+ Target.SetFoodExhaustionLevel(Target.GetFoodExhaustionLevel() + 0.025); // 0.5 per second = 0.025 per tick
}
}
@@ -194,8 +194,8 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Weakness
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectWeakness:
+
void cEntityEffectWeakness::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -212,8 +212,8 @@ void cEntityEffectWeakness::OnTick(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Poison
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectPoison:
+
void cEntityEffectPoison::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
@@ -223,9 +223,10 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
cMonster & Target = (cMonster &) a_Target;
// Doesn't effect undead mobs, spiders
- if ((Target.IsUndead())
- || (Target.GetMobType() == cMonster::mtSpider)
- || (Target.GetMobType() == cMonster::mtCaveSpider))
+ if (Target.IsUndead() ||
+ (Target.GetMobType() == cMonster::mtSpider) ||
+ (Target.GetMobType() == cMonster::mtCaveSpider)
+ )
{
return;
}
@@ -249,20 +250,19 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Wither
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectWither:
+
void cEntityEffectWither::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
- // Poison frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
+ // Damage frequency = 40 ticks, divided by effect level (Wither II = 20 ticks)
int frequency = (int) std::floor(25.0 / (double)(m_Intensity + 1));
if ((m_Ticks % frequency) == 0)
{
a_Target.TakeDamage(dtWither, NULL, 1, 0);
}
- //TODO: " withered away>
}
@@ -270,13 +270,17 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
/////////////////////////////////////////////////////////////////////////
-// Saturation
-/////////////////////////////////////////////////////////////////////////
+// cEntityEffectSaturation:
+
void cEntityEffectSaturation::OnTick(cPawn & a_Target)
{
if (a_Target.IsPlayer())
{
cPlayer & Target = (cPlayer &) a_Target;
- Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
+ Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
}
}
+
+
+
+
--
cgit v1.2.3
From f5259d765147cecb44a40ce5308387aba60cef8f Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 11:24:48 +0200
Subject: Only the cEntityEffect::effXXX constants are Lua-exported.
The rest of the classes don't need exporting, there's no interface using them anyway.
---
src/Entities/EntityEffect.cpp | 3 +-
src/Entities/EntityEffect.h | 171 ++++++++++++++++++++++++------------------
2 files changed, 102 insertions(+), 72 deletions(-)
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 761a4d651..4da7cac85 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -223,7 +223,8 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
cMonster & Target = (cMonster &) a_Target;
// Doesn't effect undead mobs, spiders
- if (Target.IsUndead() ||
+ if (
+ Target.IsUndead() ||
(Target.GetMobType() == cMonster::mtSpider) ||
(Target.GetMobType() == cMonster::mtCaveSpider)
)
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index ea0716d59..a06c1512d 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -36,6 +36,8 @@ public:
effSaturation = 23,
} ;
+ // tolua_end
+
/** Creates an empty entity effect */
cEntityEffect(void);
@@ -93,11 +95,12 @@ protected:
/** The distance modifier for affecting potency */
double m_DistanceModifier;
-};
+}; // tolua_export
+
+
+
+
-/////////////////////////////////////////////////////////////////////////
-// Speed
-/////////////////////////////////////////////////////////////////////////
class cEntityEffectSpeed:
public cEntityEffect
{
@@ -109,9 +112,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Slowness
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectSlowness:
public cEntityEffect
{
@@ -123,9 +127,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Haste
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectHaste:
public cEntityEffect
{
@@ -137,9 +142,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Mining Fatigue
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectMiningFatigue:
public cEntityEffect
{
@@ -151,9 +157,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Strength
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectStrength:
public cEntityEffect
{
@@ -165,9 +172,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Instant Health
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectInstantHealth:
public cEntityEffect
{
@@ -181,9 +189,10 @@ public:
virtual void OnActivate(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Instant Damage
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectInstantDamage:
public cEntityEffect
{
@@ -197,9 +206,10 @@ public:
virtual void OnActivate(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Jump Boost
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectJumpBoost:
public cEntityEffect
{
@@ -211,9 +221,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Nausea
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectNausea:
public cEntityEffect
{
@@ -225,9 +236,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Regeneration
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectRegeneration:
public cEntityEffect
{
@@ -241,9 +253,10 @@ public:
virtual void OnTick(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Resistance
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectResistance:
public cEntityEffect
{
@@ -255,9 +268,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Fire Resistance
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectFireResistance:
public cEntityEffect
{
@@ -269,9 +283,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Water Breathing
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectWaterBreathing:
public cEntityEffect
{
@@ -283,9 +298,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Invisibility
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectInvisibility:
public cEntityEffect
{
@@ -297,9 +313,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Blindness
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectBlindness:
public cEntityEffect
{
@@ -311,9 +328,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Night Vision
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectNightVision:
public cEntityEffect
{
@@ -325,9 +343,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Hunger
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectHunger:
public cEntityEffect
{
@@ -338,12 +357,14 @@ public:
{
}
+ // cEntityEffect overrides:
virtual void OnTick(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Weakness
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectWeakness:
public cEntityEffect
{
@@ -354,12 +375,14 @@ public:
{
}
+ // cEntityEffect overrides:
virtual void OnTick(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Poison
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectPoison:
public cEntityEffect
{
@@ -370,12 +393,14 @@ public:
{
}
+ // cEntityEffect overrides:
virtual void OnTick(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Wither
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectWither:
public cEntityEffect
{
@@ -386,12 +411,14 @@ public:
{
}
+ // cEntityEffect overrides:
virtual void OnTick(cPawn & a_Target) override;
};
-/////////////////////////////////////////////////////////////////////////
-// Health Boost
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectHealthBoost:
public cEntityEffect
{
@@ -403,9 +430,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Absorption
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectAbsorption:
public cEntityEffect
{
@@ -417,9 +445,10 @@ public:
}
};
-/////////////////////////////////////////////////////////////////////////
-// Saturation
-/////////////////////////////////////////////////////////////////////////
+
+
+
+
class cEntityEffectSaturation:
public cEntityEffect
{
@@ -435,4 +464,4 @@ public:
-// tolua_end
+
--
cgit v1.2.3
From 01a31a1872bb7c33d5a4d0a13dae083c4ef7792e Mon Sep 17 00:00:00 2001
From: Tycho
Date: Tue, 15 Jul 2014 12:27:36 +0100
Subject: Added super typedef
---
src/Blocks/BlockLadder.h | 3 ++-
src/Blocks/BlockLilypad.h | 3 ++-
src/Blocks/BlockPumpkin.h | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index 1af2be067..211bbdd9e 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -12,9 +12,10 @@
class cBlockLadderHandler :
public cClearMetaOnDrop >
{
+ typedef cClearMetaOnDrop > super;
public:
cBlockLadderHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop >(a_BlockType)
+ : super(a_BlockType)
{
}
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index c25f150c7..1320174fc 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -10,9 +10,10 @@
class cBlockLilypadHandler :
public cClearMetaOnDrop
{
+typedef cClearMetaOnDrop super;
public:
cBlockLilypadHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop(a_BlockType)
+ : super(a_BlockType)
{
}
};
diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h
index f4022735b..d2e9d7843 100644
--- a/src/Blocks/BlockPumpkin.h
+++ b/src/Blocks/BlockPumpkin.h
@@ -8,9 +8,10 @@
class cBlockPumpkinHandler :
public cClearMetaOnDrop >
{
+typedef cClearMetaOnDrop > super;
public:
cBlockPumpkinHandler(BLOCKTYPE a_BlockType)
- : cClearMetaOnDrop >(a_BlockType)
+ : super(a_BlockType)
{
}
--
cgit v1.2.3
From 2d245264b1b630dd9c6af6ffb6e6387e011a3198 Mon Sep 17 00:00:00 2001
From: Masy98
Date: Tue, 15 Jul 2014 13:34:45 +0200
Subject: Added various missing blocks in the lists in BlockInfo.cpp
---
src/BlockInfo.cpp | 277 ++++++++++++++++++++++++++++++++++++-----------
src/Blocks/BlockPiston.h | 1 -
2 files changed, 214 insertions(+), 64 deletions(-)
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 4fc1d602c..04859e586 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -14,7 +14,7 @@ cBlockInfo::cBlockInfo()
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
- , m_IsSnowable(true)
+ , m_IsSnowable(false)
, m_RequiresSpecialTool(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
@@ -65,48 +65,117 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
}
// Emissive blocks
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_LightValue = 9;
+ a_Info[E_BLOCK_BEACON ].m_LightValue = 15;
+ a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
+ a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
+ a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
+ a_Info[E_BLOCK_END_PORTAL_FRAME ].m_LightValue = 1;
+ a_Info[E_BLOCK_ENDER_CHEST ].m_LightValue = 7;
a_Info[E_BLOCK_FIRE ].m_LightValue = 15;
a_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15;
a_Info[E_BLOCK_JACK_O_LANTERN ].m_LightValue = 15;
a_Info[E_BLOCK_LAVA ].m_LightValue = 15;
- a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
- a_Info[E_BLOCK_END_PORTAL ].m_LightValue = 15;
- a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
- a_Info[E_BLOCK_TORCH ].m_LightValue = 14;
- a_Info[E_BLOCK_BURNING_FURNACE ].m_LightValue = 13;
a_Info[E_BLOCK_NETHER_PORTAL ].m_LightValue = 11;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_LightValue = 15;
a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_LightValue = 9;
a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_LightValue = 9;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_LightValue = 7;
- a_Info[E_BLOCK_BREWING_STAND ].m_LightValue = 1;
- a_Info[E_BLOCK_BROWN_MUSHROOM ].m_LightValue = 1;
- a_Info[E_BLOCK_DRAGON_EGG ].m_LightValue = 1;
+ a_Info[E_BLOCK_STATIONARY_LAVA ].m_LightValue = 15;
+ a_Info[E_BLOCK_TORCH ].m_LightValue = 14;
// Spread blocks
+ a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_AIR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ANVIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BEACON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BED ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BIG_FLOWER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BROWN_MUSHROOM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_BREWING_STAND ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CACTUS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CAKE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CARPET ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CARROTS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_CAULDRON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CHEST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_COBBLESTONE_WALL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_COCOA_POD ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_COBWEB ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_CROPS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DANDELION ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DETECTOR_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_END_PORTAL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_END_PORTAL_FRAME ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FLOWER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_FLOWER_POT ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_GLASS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_GLASS_PANE ].m_SpreadLightFalloff = 1;
- a_Info[E_BLOCK_GLOWSTONE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_HEAD ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_HOPPER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_ICE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_IRON_BARS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_IRON_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LADDER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_LEAVES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LEVER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LILY_PAD ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_MELON_STEM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_MOB_SPAWNER ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_NETHER_WART ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PISTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PISTON_EXTENSION ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_POTATOES ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_POWERED_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_PUMPKIN_STEM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_RAIL ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_RED_MUSHROOM ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SAPLING ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_SIGN_POST ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SNOW ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STAINED_GLASS ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STICKY_PISTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STONE_BUTTON ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_STONE_SLAB ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_SUGARCANE ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TALL_GRASS ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TORCH ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_TRAPDOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRAPPED_CHEST ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRIPWIRE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_VINES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
+ a_Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 1;
// Light in water and lava dissapears faster:
a_Info[E_BLOCK_LAVA ].m_SpreadLightFalloff = 3;
@@ -117,19 +186,34 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
// Transparent blocks
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_Transparent = true;
a_Info[E_BLOCK_AIR ].m_Transparent = true;
a_Info[E_BLOCK_ANVIL ].m_Transparent = true;
+ a_Info[E_BLOCK_BEACON ].m_Transparent = true;
+ a_Info[E_BLOCK_BED ].m_Transparent = true;
a_Info[E_BLOCK_BIG_FLOWER ].m_Transparent = true;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_Transparent = true;
+ a_Info[E_BLOCK_BREWING_STAND ].m_Transparent = true;
+ a_Info[E_BLOCK_CACTUS ].m_Transparent = true;
a_Info[E_BLOCK_CAKE ].m_Transparent = true;
+ a_Info[E_BLOCK_CARPET ].m_Transparent = true;
a_Info[E_BLOCK_CARROTS ].m_Transparent = true;
+ a_Info[E_BLOCK_CAULDRON ].m_Transparent = true;
a_Info[E_BLOCK_CHEST ].m_Transparent = true;
a_Info[E_BLOCK_COBBLESTONE_WALL ].m_Transparent = true;
+ a_Info[E_BLOCK_COCOA_POD ].m_Transparent = true;
a_Info[E_BLOCK_COBWEB ].m_Transparent = true;
a_Info[E_BLOCK_CROPS ].m_Transparent = true;
a_Info[E_BLOCK_DANDELION ].m_Transparent = true;
+ a_Info[E_BLOCK_DAYLIGHT_SENSOR ].m_Transparent = true;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_Transparent = true;
a_Info[E_BLOCK_DETECTOR_RAIL ].m_Transparent = true;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_Transparent = true;
+ a_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_Transparent = true;
a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true;
+ a_Info[E_BLOCK_END_PORTAL ].m_Transparent = true;
+ a_Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true;
+ a_Info[E_BLOCK_FARMLAND ].m_Transparent = true;
a_Info[E_BLOCK_FENCE ].m_Transparent = true;
a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
a_Info[E_BLOCK_FIRE ].m_Transparent = true;
@@ -139,43 +223,60 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_GLASS_PANE ].m_Transparent = true;
a_Info[E_BLOCK_HEAD ].m_Transparent = true;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_HOPPER ].m_Transparent = true;
a_Info[E_BLOCK_ICE ].m_Transparent = true;
+ a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_Transparent = true;
+ a_Info[E_BLOCK_IRON_BARS ].m_Transparent = true;
a_Info[E_BLOCK_IRON_DOOR ].m_Transparent = true;
a_Info[E_BLOCK_LADDER ].m_Transparent = true;
a_Info[E_BLOCK_LAVA ].m_Transparent = true;
a_Info[E_BLOCK_LEAVES ].m_Transparent = true;
a_Info[E_BLOCK_LEVER ].m_Transparent = true;
+ a_Info[E_BLOCK_LILY_PAD ].m_Transparent = true;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
- a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
+ a_Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true;
a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
+ a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_Transparent = true;
a_Info[E_BLOCK_POTATOES ].m_Transparent = true;
a_Info[E_BLOCK_POWERED_RAIL ].m_Transparent = true;
- a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_Transparent = true;
a_Info[E_BLOCK_RAIL ].m_Transparent = true;
a_Info[E_BLOCK_RED_MUSHROOM ].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_Transparent = true;
+ a_Info[E_BLOCK_REDSTONE_WIRE ].m_Transparent = true;
+ a_Info[E_BLOCK_SAPLING ].m_Transparent = true;
a_Info[E_BLOCK_SIGN_POST ].m_Transparent = true;
a_Info[E_BLOCK_SNOW ].m_Transparent = true;
a_Info[E_BLOCK_STAINED_GLASS ].m_Transparent = true;
a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_Transparent = true;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_Transparent = true;
a_Info[E_BLOCK_STATIONARY_WATER ].m_Transparent = true;
+ a_Info[E_BLOCK_STICKY_PISTON ].m_Transparent = true;
a_Info[E_BLOCK_STONE_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_Transparent = true;
+ a_Info[E_BLOCK_STONE_SLAB ].m_Transparent = true;
+ a_Info[E_BLOCK_SUGARCANE ].m_Transparent = true;
+ a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
+ a_Info[E_BLOCK_TORCH ].m_Transparent = true;
+ a_Info[E_BLOCK_TRAPDOOR ].m_Transparent = true;
a_Info[E_BLOCK_TRAPPED_CHEST ].m_Transparent = true;
a_Info[E_BLOCK_TRIPWIRE ].m_Transparent = true;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_Transparent = true;
- a_Info[E_BLOCK_TALL_GRASS ].m_Transparent = true;
- a_Info[E_BLOCK_TORCH ].m_Transparent = true;
a_Info[E_BLOCK_VINES ].m_Transparent = true;
a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
a_Info[E_BLOCK_WATER ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
-
- // TODO: Any other transparent blocks?
+ a_Info[E_BLOCK_WOODEN_SLAB ].m_Transparent = true;
// One hit break blocks:
@@ -185,10 +286,12 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_CARROTS ].m_OneHitDig = true;
a_Info[E_BLOCK_CROPS ].m_OneHitDig = true;
a_Info[E_BLOCK_DANDELION ].m_OneHitDig = true;
+ a_Info[E_BLOCK_DEAD_BUSH ].m_OneHitDig = true;
a_Info[E_BLOCK_FIRE ].m_OneHitDig = true;
a_Info[E_BLOCK_FLOWER ].m_OneHitDig = true;
a_Info[E_BLOCK_FLOWER_POT ].m_OneHitDig = true;
a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_OneHitDig = true;
+ a_Info[E_BLOCK_LILY_PAD ].m_OneHitDig = true;
a_Info[E_BLOCK_MELON_STEM ].m_OneHitDig = true;
a_Info[E_BLOCK_POTATOES ].m_OneHitDig = true;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_OneHitDig = true;
@@ -212,24 +315,32 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_BED ].m_PistonBreakable = true;
a_Info[E_BLOCK_BIG_FLOWER ].m_PistonBreakable = true;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CACTUS ].m_PistonBreakable = true;
a_Info[E_BLOCK_CAKE ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_CARROTS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_COCOA_POD ].m_PistonBreakable = true;
a_Info[E_BLOCK_COBWEB ].m_PistonBreakable = true;
a_Info[E_BLOCK_CROPS ].m_PistonBreakable = true;
a_Info[E_BLOCK_DANDELION ].m_PistonBreakable = true;
a_Info[E_BLOCK_DEAD_BUSH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_DRAGON_EGG ].m_PistonBreakable = true;
a_Info[E_BLOCK_FIRE ].m_PistonBreakable = true;
a_Info[E_BLOCK_FLOWER ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_FLOWER_POT ].m_PistonBreakable = true;
a_Info[E_BLOCK_HEAD ].m_PistonBreakable = true;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_IRON_DOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_JACK_O_LANTERN ].m_PistonBreakable = true;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_PistonBreakable = true;
+ a_Info[E_BLOCK_LILY_PAD ].m_PistonBreakable = true;
a_Info[E_BLOCK_LADDER ].m_PistonBreakable = true;
a_Info[E_BLOCK_LAVA ].m_PistonBreakable = true;
a_Info[E_BLOCK_LEVER ].m_PistonBreakable = true;
a_Info[E_BLOCK_MELON ].m_PistonBreakable = true;
a_Info[E_BLOCK_MELON_STEM ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_NETHER_WART ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_POTATOES ].m_PistonBreakable = true;
a_Info[E_BLOCK_PUMPKIN ].m_PistonBreakable = true;
a_Info[E_BLOCK_PUMPKIN_STEM ].m_PistonBreakable = true;
a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_PistonBreakable = true;
@@ -239,6 +350,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_REDSTONE_WIRE ].m_PistonBreakable = true;
a_Info[E_BLOCK_RED_MUSHROOM ].m_PistonBreakable = true;
a_Info[E_BLOCK_REEDS ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_SAPLING ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_SIGN_POST ].m_PistonBreakable = true;
a_Info[E_BLOCK_SNOW ].m_PistonBreakable = true;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_PistonBreakable = true;
a_Info[E_BLOCK_STATIONARY_WATER ].m_PistonBreakable = true;
@@ -246,61 +359,85 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_PistonBreakable = true;
a_Info[E_BLOCK_TALL_GRASS ].m_PistonBreakable = true;
a_Info[E_BLOCK_TORCH ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_TRAPDOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_TRIPWIRE ].m_PistonBreakable = true;
a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_PistonBreakable = true;
a_Info[E_BLOCK_VINES ].m_PistonBreakable = true;
+ a_Info[E_BLOCK_WALLSIGN ].m_PistonBreakable = true;
a_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
- // Blocks that cannot be snowed over:
- a_Info[E_BLOCK_ACTIVE_COMPARATOR ].m_IsSnowable = false;
- a_Info[E_BLOCK_AIR ].m_IsSnowable = false;
- a_Info[E_BLOCK_BIG_FLOWER ].m_IsSnowable = false;
- a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSnowable = false;
- a_Info[E_BLOCK_CACTUS ].m_IsSnowable = false;
- a_Info[E_BLOCK_CHEST ].m_IsSnowable = false;
- a_Info[E_BLOCK_CROPS ].m_IsSnowable = false;
- a_Info[E_BLOCK_COBBLESTONE_WALL ].m_IsSnowable = false;
- a_Info[E_BLOCK_DANDELION ].m_IsSnowable = false;
- a_Info[E_BLOCK_FIRE ].m_IsSnowable = false;
- a_Info[E_BLOCK_FLOWER ].m_IsSnowable = false;
- a_Info[E_BLOCK_GLASS ].m_IsSnowable = false;
- a_Info[E_BLOCK_ICE ].m_IsSnowable = false;
- a_Info[E_BLOCK_INACTIVE_COMPARATOR ].m_IsSnowable = false;
- a_Info[E_BLOCK_LAVA ].m_IsSnowable = false;
- a_Info[E_BLOCK_LILY_PAD ].m_IsSnowable = false;
- a_Info[E_BLOCK_REDSTONE_REPEATER_OFF].m_IsSnowable = false;
- a_Info[E_BLOCK_REDSTONE_REPEATER_ON].m_IsSnowable = false;
- a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSnowable = false;
- a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSnowable = false;
- a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSnowable = false;
- a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSnowable = false;
- a_Info[E_BLOCK_REEDS ].m_IsSnowable = false;
- a_Info[E_BLOCK_SAPLING ].m_IsSnowable = false;
- a_Info[E_BLOCK_SIGN_POST ].m_IsSnowable = false;
- a_Info[E_BLOCK_SNOW ].m_IsSnowable = false;
- a_Info[E_BLOCK_STAINED_GLASS ].m_IsSnowable = false;
- a_Info[E_BLOCK_STAINED_GLASS_PANE ].m_IsSnowable = false;
- a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSnowable = false;
- a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSnowable = false;
- a_Info[E_BLOCK_TALL_GRASS ].m_IsSnowable = false;
- a_Info[E_BLOCK_TNT ].m_IsSnowable = false;
- a_Info[E_BLOCK_TORCH ].m_IsSnowable = false;
- a_Info[E_BLOCK_TRAPPED_CHEST ].m_IsSnowable = false;
- a_Info[E_BLOCK_TRIPWIRE ].m_IsSnowable = false;
- a_Info[E_BLOCK_TRIPWIRE_HOOK ].m_IsSnowable = false;
- a_Info[E_BLOCK_VINES ].m_IsSnowable = false;
- a_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
- a_Info[E_BLOCK_WATER ].m_IsSnowable = false;
- a_Info[E_BLOCK_RAIL ].m_IsSnowable = false;
- a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false;
- a_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false;
- a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false;
- a_Info[E_BLOCK_COBWEB ].m_IsSnowable = false;
- a_Info[E_BLOCK_HEAD ].m_IsSnowable = false;
+ // Blocks that can be snowed over:
+ a_Info[E_BLOCK_BEDROCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BLOCK_OF_COAL ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BLOCK_OF_REDSTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BOOKCASE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_BRICK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_CLAY ].m_IsSnowable = true;
+ a_Info[E_BLOCK_CRAFTING_TABLE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_COAL_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_COMMAND_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_COBBLESTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DIAMOND_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DIAMOND_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DIRT ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DISPENSER ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_IsSnowable = true;
+ a_Info[E_BLOCK_DROPPER ].m_IsSnowable = true;
+ a_Info[E_BLOCK_EMERALD_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_EMERALD_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_END_STONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_FURNACE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GLOWSTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GOLD_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GOLD_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GRASS ].m_IsSnowable = true;
+ a_Info[E_BLOCK_GRAVEL ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HARDENED_CLAY ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HAY_BALE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HUGE_BROWN_MUSHROOM ].m_IsSnowable = true;
+ a_Info[E_BLOCK_HUGE_RED_MUSHROOM ].m_IsSnowable = true;
+ a_Info[E_BLOCK_IRON_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_IRON_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_JACK_O_LANTERN ].m_IsSnowable = true;
+ a_Info[E_BLOCK_JUKEBOX ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LAPIS_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LAPIS_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LEAVES ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LIT_FURNACE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_LOG ].m_IsSnowable = true;
+ a_Info[E_BLOCK_MELON ].m_IsSnowable = true;
+ a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_MYCELIUM ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NETHER_BRICK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NETHER_QUARTZ_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NETHERRACK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NEW_LEAVES ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NEW_LOG ].m_IsSnowable = true;
+ a_Info[E_BLOCK_NOTE_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_OBSIDIAN ].m_IsSnowable = true;
+ a_Info[E_BLOCK_PLANKS ].m_IsSnowable = true;
+ a_Info[E_BLOCK_PUMPKIN ].m_IsSnowable = true;
+ a_Info[E_BLOCK_QUARTZ_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_OFF ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_LAMP_ON ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_ORE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_REDSTONE_ORE_GLOWING].m_IsSnowable = true;
+ a_Info[E_BLOCK_SAND ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SANDSTONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SILVERFISH_EGG ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SNOW_BLOCK ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SOULSAND ].m_IsSnowable = true;
+ a_Info[E_BLOCK_SPONGE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_STAINED_CLAY ].m_IsSnowable = true;
+ a_Info[E_BLOCK_STONE ].m_IsSnowable = true;
+ a_Info[E_BLOCK_STONE_BRICKS ].m_IsSnowable = true;
+ a_Info[E_BLOCK_TNT ].m_IsSnowable = true;
+ a_Info[E_BLOCK_WOOL ].m_IsSnowable = true;
// Blocks that don't drop without a special tool:
@@ -323,6 +460,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_IRON_ORE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LAPIS_BLOCK ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LAPIS_ORE ].m_RequiresSpecialTool = true;
+ a_Info[E_BLOCK_LEAVES ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_MOSSY_COBBLESTONE ].m_RequiresSpecialTool = true;
a_Info[E_BLOCK_NETHERRACK ].m_RequiresSpecialTool = true;
@@ -347,15 +485,21 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
// Nonsolid blocks:
+ a_Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_AIR ].m_IsSolid = false;
a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
+ a_Info[E_BLOCK_BIRCH_WOOD_STAIRS ].m_IsSolid = false;
+ a_Info[E_BLOCK_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_CAKE ].m_IsSolid = false;
+ a_Info[E_BLOCK_CARPET ].m_IsSolid = false;
a_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
+ a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
a_Info[E_BLOCK_CROPS ].m_IsSolid = false;
a_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
+ a_Info[E_BLOCK_DARK_OAK_WOOD_STAIRS].m_IsSolid = false;
a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
a_Info[E_BLOCK_FENCE ].m_IsSolid = false;
@@ -363,24 +507,30 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_FIRE ].m_IsSolid = false;
a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
+ a_Info[E_BLOCK_JUNGLE_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_LAVA ].m_IsSolid = false;
a_Info[E_BLOCK_LEVER ].m_IsSolid = false;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
+ a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
a_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
+ a_Info[E_BLOCK_QUARTZ_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_REEDS ].m_IsSolid = false;
+ a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
a_Info[E_BLOCK_SNOW ].m_IsSolid = false;
+ a_Info[E_BLOCK_SPRUCE_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
+ a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
@@ -392,6 +542,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
+ a_Info[E_BLOCK_WOODEN_STAIRS ].m_IsSolid = false;
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:
@@ -455,9 +606,9 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_SILVERFISH_EGG ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_SPONGE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STAINED_CLAY ].m_FullyOccupiesVoxel = true;
- a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STONE ].m_FullyOccupiesVoxel = true;
a_Info[E_BLOCK_STONE_BRICKS ].m_FullyOccupiesVoxel = true;
+ a_Info[E_BLOCK_WOOL ].m_FullyOccupiesVoxel = true;
}
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index 27a44d829..1c8ac6a35 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -94,7 +94,6 @@ private:
switch (a_BlockType)
{
case E_BLOCK_ANVIL:
- case E_BLOCK_BED:
case E_BLOCK_BEDROCK:
case E_BLOCK_BREWING_STAND:
case E_BLOCK_CHEST:
--
cgit v1.2.3
From 57f4e871bb820beaf56ee48e762a1ee276aa8afe Mon Sep 17 00:00:00 2001
From: Tycho
Date: Tue, 15 Jul 2014 12:52:02 +0100
Subject: Fixed FindClosestPlayer
---
src/World.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/World.cpp b/src/World.cpp
index ba8add8f0..bd3613ce2 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2468,10 +2468,13 @@ cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit,
if (Distance < ClosestDistance)
{
- if (a_CheckLineOfSight && !LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length()))
+ if (a_CheckLineOfSight)
{
- ClosestDistance = Distance;
- ClosestPlayer = *itr;
+ if(!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length()))
+ {
+ ClosestDistance = Distance;
+ ClosestPlayer = *itr;
+ }
}
else
{
--
cgit v1.2.3
From 7f4029f8f4b9b0c0b711c631ce704a3bbcb6e990 Mon Sep 17 00:00:00 2001
From: Masy98
Date: Tue, 15 Jul 2014 14:06:03 +0200
Subject: Added Brick fence to m_Transparent
---
src/BlockInfo.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 04859e586..d902ea4a6 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -236,6 +236,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_MELON_STEM ].m_Transparent = true;
a_Info[E_BLOCK_MOB_SPAWNER ].m_Transparent = true;
+ a_Info[E_BLOCK_NETHER_BRICK_FENCE ].m_Transparent = true;
a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true;
a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true;
a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
--
cgit v1.2.3
From 9a970479efaef781ea8f69e3d8b8a1e2aa367847 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 14:54:24 +0200
Subject: Fixed code formatting.
---
src/Blocks/BlockLilypad.h | 7 ++++---
src/Blocks/BlockPumpkin.h | 8 +++++---
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index 1320174fc..53277caa5 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -10,10 +10,11 @@
class cBlockLilypadHandler :
public cClearMetaOnDrop
{
-typedef cClearMetaOnDrop super;
+ typedef cClearMetaOnDrop super;
public:
- cBlockLilypadHandler(BLOCKTYPE a_BlockType)
- : super(a_BlockType)
+
+ cBlockLilypadHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
{
}
};
diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h
index d2e9d7843..4692a47df 100644
--- a/src/Blocks/BlockPumpkin.h
+++ b/src/Blocks/BlockPumpkin.h
@@ -8,12 +8,14 @@
class cBlockPumpkinHandler :
public cClearMetaOnDrop >
{
-typedef cClearMetaOnDrop > super;
+ typedef cClearMetaOnDrop > super;
public:
- cBlockPumpkinHandler(BLOCKTYPE a_BlockType)
- : super(a_BlockType)
+
+ cBlockPumpkinHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
{
}
+
virtual void OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
{
--
cgit v1.2.3
From 74b6bf01a9932b12cb4ce6588086bfb00bf305a0 Mon Sep 17 00:00:00 2001
From: Howaner
Date: Tue, 15 Jul 2014 18:33:28 +0200
Subject: Derp.
---
src/ChunkMap.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index d25f6d64b..9bc3e5c49 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1854,14 +1854,14 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
case E_BLOCK_STATIONARY_WATER:
{
// Turn into simulated water:
- area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_WATER, 0);
+ area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_WATER);
break;
}
case E_BLOCK_STATIONARY_LAVA:
{
// Turn into simulated lava:
- area.SetBlockTypeMeta(bx + x, by + y, bz + z, E_BLOCK_LAVA, 0);
+ area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_LAVA);
break;
}
--
cgit v1.2.3
From d272e468212b2956f419fd1b595329f994151944 Mon Sep 17 00:00:00 2001
From: Masy98
Date: Tue, 15 Jul 2014 20:32:49 +0200
Subject: Removed Stairs and carpet from the "isSolid" list to prevent mobs
falling through them.
---
src/BlockInfo.cpp | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index d902ea4a6..548b87ca8 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -486,21 +486,16 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
// Nonsolid blocks:
- a_Info[E_BLOCK_ACACIA_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_AIR ].m_IsSolid = false;
a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
- a_Info[E_BLOCK_BIRCH_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_CAKE ].m_IsSolid = false;
- a_Info[E_BLOCK_CARPET ].m_IsSolid = false;
a_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
- a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_COBWEB ].m_IsSolid = false;
a_Info[E_BLOCK_CROPS ].m_IsSolid = false;
a_Info[E_BLOCK_DANDELION ].m_IsSolid = false;
- a_Info[E_BLOCK_DARK_OAK_WOOD_STAIRS].m_IsSolid = false;
a_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_END_PORTAL ].m_IsSolid = false;
a_Info[E_BLOCK_FENCE ].m_IsSolid = false;
@@ -508,30 +503,24 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_FIRE ].m_IsSolid = false;
a_Info[E_BLOCK_FLOWER ].m_IsSolid = false;
a_Info[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
- a_Info[E_BLOCK_JUNGLE_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_LAVA ].m_IsSolid = false;
a_Info[E_BLOCK_LEVER ].m_IsSolid = false;
a_Info[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_MELON_STEM ].m_IsSolid = false;
- a_Info[E_BLOCK_NETHER_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_NETHER_PORTAL ].m_IsSolid = false;
a_Info[E_BLOCK_POTATOES ].m_IsSolid = false;
a_Info[E_BLOCK_POWERED_RAIL ].m_IsSolid = false;
- a_Info[E_BLOCK_QUARTZ_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_TORCH_OFF ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_TORCH_ON ].m_IsSolid = false;
a_Info[E_BLOCK_REDSTONE_WIRE ].m_IsSolid = false;
a_Info[E_BLOCK_RED_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_REEDS ].m_IsSolid = false;
- a_Info[E_BLOCK_SANDSTONE_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_SAPLING ].m_IsSolid = false;
a_Info[E_BLOCK_SIGN_POST ].m_IsSolid = false;
a_Info[E_BLOCK_SNOW ].m_IsSolid = false;
- a_Info[E_BLOCK_SPRUCE_WOOD_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_STATIONARY_LAVA ].m_IsSolid = false;
a_Info[E_BLOCK_STATIONARY_WATER ].m_IsSolid = false;
- a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_STONE_BUTTON ].m_IsSolid = false;
a_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_TALL_GRASS ].m_IsSolid = false;
@@ -543,7 +532,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_WOODEN_BUTTON ].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_IsSolid = false;
a_Info[E_BLOCK_WOODEN_SLAB ].m_IsSolid = false;
- a_Info[E_BLOCK_WOODEN_STAIRS ].m_IsSolid = false;
// Blocks that fully occupy their voxel - used as a guide for torch placeable blocks, amongst other things:
--
cgit v1.2.3
From b5794517315f3e08d847332111537068e2b8af53 Mon Sep 17 00:00:00 2001
From: Masy98
Date: Tue, 15 Jul 2014 20:34:49 +0200
Subject: Removed Stairs and carpet from the "isSolid" list to prevent mobs
falling through them.
---
src/BlockInfo.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 548b87ca8..b4b98a2f0 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -489,7 +489,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSolid = false;
a_Info[E_BLOCK_AIR ].m_IsSolid = false;
a_Info[E_BLOCK_BIG_FLOWER ].m_IsSolid = false;
- a_Info[E_BLOCK_BRICK_STAIRS ].m_IsSolid = false;
a_Info[E_BLOCK_BROWN_MUSHROOM ].m_IsSolid = false;
a_Info[E_BLOCK_CAKE ].m_IsSolid = false;
a_Info[E_BLOCK_CARROTS ].m_IsSolid = false;
--
cgit v1.2.3
From cc452f51c8c4e1c886932d2f7965c7b3e4ab42fe Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Tue, 15 Jul 2014 22:41:42 +0200
Subject: Restructured cSplashPotionEntity code.
The callback doesn't need declaration in the header.
Renamed PotionName to PotionParticleType.
---
src/Entities/EntityEffect.h | 19 ++++--
src/Entities/SplashPotionEntity.cpp | 107 ++++++++++++++++++++------------
src/Entities/SplashPotionEntity.h | 46 ++++++--------
src/WorldStorage/NBTChunkSerializer.cpp | 2 +-
src/WorldStorage/WSSAnvil.cpp | 2 +-
5 files changed, 104 insertions(+), 72 deletions(-)
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index a06c1512d..ebd611ff0 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -7,7 +7,7 @@ class cEntityEffect
{
public:
- /** All types of entity effects (numbers correspond to IDs) */
+ /** All types of entity effects (numbers correspond to protocol / storage types) */
enum eType
{
effNoEffect = 0,
@@ -66,21 +66,30 @@ public:
static cEntityEffect * CreateEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier);
/** Returns how many ticks this effect has been active for */
- int GetTicks() { return m_Ticks; }
+ int GetTicks(void) const { return m_Ticks; }
+
/** Returns the duration of the effect */
- int GetDuration() { return m_Duration; }
+ int GetDuration(void) const { return m_Duration; }
+
/** Returns how strong the effect will be applied */
- short GetIntensity() { return m_Intensity; }
+ short GetIntensity(void) const { return m_Intensity; }
+
/** Returns the distance modifier for affecting potency */
- double GetDistanceModifier() { return m_DistanceModifier; }
+ double GetDistanceModifier(void) const { return m_DistanceModifier; }
void SetTicks(int a_Ticks) { m_Ticks = a_Ticks; }
void SetDuration(int a_Duration) { m_Duration = a_Duration; }
void SetIntensity(short a_Intensity) { m_Intensity = a_Intensity; }
void SetDistanceModifier(double a_DistanceModifier) { m_DistanceModifier = a_DistanceModifier; }
+ /** Called on each tick.
+ By default increases the m_Ticks, descendants may override to provide additional processing. */
virtual void OnTick(cPawn & a_Target);
+
+ /** Called when the effect is first added to an entity */
virtual void OnActivate(cPawn & a_Target) { }
+
+ /** Called when the effect is removed from an entity */
virtual void OnDeactivate(cPawn & a_Target) { }
protected:
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index e84f1c430..804026cc0 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -7,11 +7,77 @@
-cSplashPotionEntity::cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName) :
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSplashPotionEntityCallback:
+
+/** Used to distribute the splashed potion effect among nearby entities */
+class cSplashPotionCallback :
+ public cEntityCallback
+{
+public:
+ /** Creates the callback.
+ @param a_HitPos The position where the splash potion has splashed
+ @param a_EntityEffectType The effect type of the potion
+ @param a_EntityEffect The effect description */
+ cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType a_EntityEffectType, const cEntityEffect & a_EntityEffect) :
+ m_HitPos(a_HitPos),
+ m_EntityEffectType(a_EntityEffectType),
+ m_EntityEffect(a_EntityEffect)
+ {
+ }
+
+ /** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
+ if (SplashDistance >= 20)
+ {
+ // Too far away
+ return false;
+ }
+ if (!a_Entity->IsPawn())
+ {
+ // Not an entity that can take effects
+ return false;
+ }
+
+ // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
+ // TODO: better equation
+ double Reduction = -0.25 * SplashDistance + 1.0;
+ if (Reduction < 0)
+ {
+ Reduction = 0;
+ }
+
+ ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
+ return false;
+ }
+
+private:
+ const Vector3d & m_HitPos;
+ cEntityEffect::eType m_EntityEffectType;
+ const cEntityEffect & m_EntityEffect;
+};
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSplashPotionEntity:
+
+cSplashPotionEntity::cSplashPotionEntity(
+ cEntity * a_Creator,
+ double a_X, double a_Y, double a_Z,
+ const Vector3d & a_Speed,
+ cEntityEffect::eType a_EntityEffectType,
+ cEntityEffect a_EntityEffect,
+ int a_PotionParticleType
+) :
super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
m_EntityEffectType(a_EntityEffectType),
m_EntityEffect(a_EntityEffect),
- m_PotionName(a_PotionName)
+ m_PotionParticleType(a_PotionParticleType)
{
SetSpeed(a_Speed);
}
@@ -46,42 +112,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
- m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName);
-}
-
-
-
-
-
-cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect):
- m_HitPos(a_HitPos),
- m_EntityEffectType(a_EntityEffectType),
- m_EntityEffect(a_EntityEffect)
-{
-
-}
-
-
-
-
-
-bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity)
-{
- double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
- if (SplashDistance < 20 && a_Entity->IsPawn())
- {
- // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
- // TODO: better equation
- double Reduction = -0.25 * SplashDistance + 1.0;
- if (Reduction < 0)
- {
- Reduction = 0;
- }
-
- m_EntityEffect.SetDistanceModifier(Reduction);
- ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
- }
- return false;
+ m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionParticleType);
}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index ad656d8ab..076e477da 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -25,43 +25,35 @@ public:
CLASS_PROTODEF(cSplashPotionEntity);
- cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName);
-
- cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; }
- cEntityEffect GetEntityEffect() { return m_EntityEffect; }
- int GetPotionName() { return m_PotionName; }
+ cSplashPotionEntity(
+ cEntity * a_Creator,
+ double a_X, double a_Y, double a_Z,
+ const Vector3d & a_Speed,
+ cEntityEffect::eType a_EntityEffectType,
+ cEntityEffect a_EntityEffect,
+ int a_PotionParticleType
+ );
+
+ cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; }
+ cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; }
+ int GetPotionParticleType(void) const { return m_PotionParticleType; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
- void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; }
+ void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; }
protected:
+ cEntityEffect::eType m_EntityEffectType;
+ cEntityEffect m_EntityEffect;
+ int m_PotionParticleType;
+
+
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
/** Splashes the potion, fires its particle effects and sounds
- * @param a_HitPos The position where the potion will splash
- */
+ @param a_HitPos The position where the potion will splash */
void Splash(const Vector3d & a_HitPos);
-
- cEntityEffect::eType m_EntityEffectType;
- cEntityEffect m_EntityEffect;
- int m_PotionName;
-
- class cSplashPotionCallback :
- public cEntityCallback
- {
- public:
- cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect);
-
- virtual bool Item(cEntity *a_Entity) override;
-
- private:
- const Vector3d &m_HitPos;
- cEntityEffect::eType &m_EntityEffectType;
- cEntityEffect &m_EntityEffect;
- };
-
} ; // tolua_export
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 82c8df947..6d0b60371 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -613,7 +613,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
- m_Writer.AddInt("PotionName", Potion->GetPotionName());
+ m_Writer.AddInt("PotionName", Potion->GetPotionParticleType());
}
case cProjectileEntity::pkGhastFireball:
{
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 0319173f8..1a43cf4ba 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
- SplashPotion->SetPotionName(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
+ SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
a_Entities.push_back(SplashPotion.release());
--
cgit v1.2.3
From 1df5a1f237cd4b620ada8aa9706d052ec54f1519 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Tue, 15 Jul 2014 22:53:44 +0100
Subject: Fixed a DropSpenser AddFace bug
---
src/BlockEntities/DropSpenserEntity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 0012742fb..108c2ce1b 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity()
void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
{
- switch (a_Direction)
+ switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't
{
case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
--
cgit v1.2.3
From 1f6854792cdd6792b27c4f9f3d7d857df9dd64bf Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 00:03:47 +0100
Subject: Store properties as Json::Value
---
src/ClientHandle.cpp | 2 +-
src/ClientHandle.h | 11 +++++++----
src/Protocol/Authenticator.cpp | 15 ++++++++++-----
src/Protocol/Authenticator.h | 9 ++++++++-
src/Protocol/Protocol17x.cpp | 8 ++------
src/Root.cpp | 2 +-
src/Root.h | 7 ++++++-
src/Server.cpp | 2 +-
src/Server.h | 9 ++++++++-
9 files changed, 44 insertions(+), 21 deletions(-)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index fcd8d2bcd..c749d41ab 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -290,7 +290,7 @@ void cClientHandle::Kick(const AString & a_Reason)
-void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties)
+void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
if (m_State != csAuthenticating)
{
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 478da5b3c..7bd286a05 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -20,6 +20,7 @@
#include "Map.h"
#include "Enchantments.h"
#include "UI/SlotArea.h"
+#include "json/json.h"
@@ -68,7 +69,7 @@ public:
const AString & GetUUID(void) const { return m_UUID; } // tolua_export
void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; }
- const AString & GetProperties(void) const { return m_Properties; }
+ const Json::Value & GetProperties(void) const { return m_Properties; }
/** Generates an UUID based on the username stored for this client, and stores it in the m_UUID member.
This is used for the offline (non-auth) mode, when there's no UUID source.
@@ -93,8 +94,10 @@ public:
static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
- void Kick(const AString & a_Reason); // tolua_export
- void Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator when the user passes authentication
+ void Kick(const AString & a_Reason); // tolua_export
+
+ /** Authenticates the specified user, called by cAuthenticator */
+ void Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties);
void StreamChunks(void);
@@ -282,7 +285,7 @@ private:
AString m_Username;
AString m_Password;
- AString m_Properties;
+ Json::Value m_Properties;
cCriticalSection m_CSChunkLists;
cChunkCoordsList m_LoadedChunks; // Chunks that the player belongs to
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 8fd8952e8..c01d748c6 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -115,7 +115,8 @@ void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, co
{
if (!m_ShouldAuthenticate)
{
- cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName));
+ Json::Value Value;
+ cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName), Value);
return;
}
@@ -177,7 +178,7 @@ void cAuthenticator::Execute(void)
AString UUID;
if (AuthWithYggdrasil(NewUserName, ServerID, UUID))
{
- AString Properties;
+ Json::Value Properties;
if (!GetPlayerProperties(UUID, Properties))
{
LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str());
@@ -329,7 +330,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
-bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Properties)
+bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties)
{
LOGD("Trying to get properties for user %s", a_UUID.c_str());
@@ -383,6 +384,10 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Pro
return false;
}
- a_Properties = root["properties"].toStyledString();
+ a_Properties = root["properties"];
return true;
-}
\ No newline at end of file
+}
+
+
+
+
diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h
index 04fa3e09c..9f6dd60ca 100644
--- a/src/Protocol/Authenticator.h
+++ b/src/Protocol/Authenticator.h
@@ -23,6 +23,11 @@
// fwd: "cRoot.h"
class cRoot;
+namespace Json
+{
+ class Value;
+}
+
@@ -79,12 +84,14 @@ private:
/** cIsThread override: */
virtual void Execute(void) override;
+ /** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */
bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response);
/** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */
bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID);
- bool GetPlayerProperties(const AString & a_UUID, AString & a_Properties);
+ /** Gets the properties, such as skin, of a player based on their UUID via Mojang's API */
+ bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties);
};
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index ae800e9cf..d3b1cf946 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -3016,12 +3016,8 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
Pkt.WriteString(a_Player.GetClientHandle()->GetUUID());
Pkt.WriteString(a_Player.GetName());
- Json::Value root;
- Json::Reader reader;
- reader.parse(m_Client->GetProperties(), root);
-
- Pkt.WriteVarInt(root.size());
- for (Json::Value::iterator itr = root.begin(); itr != root.end(); ++itr)
+ Pkt.WriteVarInt(m_Client->GetProperties().size());
+ for (Json::Value::iterator itr = m_Client->GetProperties().begin(); itr != m_Client->GetProperties().end(); ++itr)
{
Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString());
Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString());
diff --git a/src/Root.cpp b/src/Root.cpp
index c578fe6a3..ec1351ef1 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -499,7 +499,7 @@ void cRoot::KickUser(int a_ClientID, const AString & a_Reason)
-void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties)
+void cRoot::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
m_Server->AuthenticateUser(a_ClientID, a_Name, a_UUID, a_Properties);
}
diff --git a/src/Root.h b/src/Root.h
index a9e985656..4a3c205d3 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -26,6 +26,11 @@ class cCompositeChat;
typedef cItemCallback cPlayerListCallback;
typedef cItemCallback cWorldListCallback;
+namespace Json
+{
+ class Value;
+}
+
@@ -89,7 +94,7 @@ public:
void KickUser(int a_ClientID, const AString & a_Reason);
/// Called by cAuthenticator to auth the specified user
- void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties = "");
+ void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties);
/// Executes commands queued in the command queue
void TickCommands(void);
diff --git a/src/Server.cpp b/src/Server.cpp
index 8b479292e..17551eeb1 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -656,7 +656,7 @@ void cServer::KickUser(int a_ClientID, const AString & a_Reason)
-void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties)
+void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
cCSLock Lock(m_CSClients);
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
diff --git a/src/Server.h b/src/Server.h
index 672dc26c0..cf5fa524f 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -41,6 +41,11 @@ class cCommandOutputCallback;
typedef std::list cClientHandleList;
+namespace Json
+{
+ class Value;
+}
+
@@ -83,7 +88,9 @@ public: // tolua_export
void Shutdown(void);
void KickUser(int a_ClientID, const AString & a_Reason);
- void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const AString & a_Properties); // Called by cAuthenticator to auth the specified user
+
+ /** Authenticates the specified user, called by cAuthenticator */
+ void AuthenticateUser(int a_ClientID, const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties);
const AString & GetServerID(void) const { return m_ServerID; } // tolua_export
--
cgit v1.2.3
From f2c4f56ccd1862fb6d02f6f2dfb3230123f465cf Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 11:21:02 +0100
Subject: Unified functions
Thanks @Howaner!
---
src/Protocol/Authenticator.cpp | 51 +++++++++++++++++++-----------------------
src/Protocol/Authenticator.h | 11 +++++----
2 files changed, 28 insertions(+), 34 deletions(-)
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index c01d748c6..28df0f882 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -17,7 +17,6 @@
#define DEFAULT_AUTH_SERVER "sessionserver.mojang.com"
#define DEFAULT_AUTH_ADDRESS "/session/minecraft/hasJoined?username=%USERNAME%&serverId=%SERVERID%"
-#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%"
/** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert:
Downloaded from http://certs.starfieldtech.com/repository/ */
@@ -81,7 +80,6 @@ cAuthenticator::cAuthenticator(void) :
super("cAuthenticator"),
m_Server(DEFAULT_AUTH_SERVER),
m_Address(DEFAULT_AUTH_ADDRESS),
- m_PropertiesAddress(DEFAULT_PROPERTIES_ADDRESS),
m_ShouldAuthenticate(true)
{
}
@@ -103,7 +101,6 @@ void cAuthenticator::ReadINI(cIniFile & IniFile)
{
m_Server = IniFile.GetValueSet("Authentication", "Server", DEFAULT_AUTH_SERVER);
m_Address = IniFile.GetValueSet("Authentication", "Address", DEFAULT_AUTH_ADDRESS);
- m_PropertiesAddress = IniFile.GetValueSet("Authentication", "PlayerPropertiesAddress", DEFAULT_PROPERTIES_ADDRESS);
m_ShouldAuthenticate = IniFile.GetValueSetB("Authentication", "Authenticate", true);
}
@@ -176,27 +173,10 @@ void cAuthenticator::Execute(void)
AString NewUserName = UserName;
AString UUID;
- if (AuthWithYggdrasil(NewUserName, ServerID, UUID))
+ Json::Value Properties;
+ if (AuthWithYggdrasil(NewUserName, ServerID, UUID, Properties))
{
- Json::Value Properties;
- if (!GetPlayerProperties(UUID, Properties))
- {
- LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str());
- }
- else
- {
- LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str());
- }
-
- // If the UUID doesn't contain the hashes, insert them at the proper places:
- if (UUID.size() == 32)
- {
- UUID.insert(8, "-");
- UUID.insert(13, "-");
- UUID.insert(18, "-");
- UUID.insert(23, "-");
- }
-
+ LOGINFO("User %s authenticated with UUID %s", NewUserName.c_str(), UUID.c_str());
cRoot::Get()->AuthenticateUser(ClientID, NewUserName, UUID, Properties);
}
else
@@ -266,7 +246,7 @@ bool cAuthenticator::ConnectSecurelyToAddress(const AString & a_CACerts, const A
-bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID)
+bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties)
{
LOGD("Trying to authenticate user %s", a_UserName.c_str());
@@ -322,6 +302,16 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
}
a_UserName = root.get("name", "Unknown").asString();
a_UUID = root.get("id", "").asString();
+ a_Properties = root["properties"];
+
+ // If the UUID doesn't contain the hashes, insert them at the proper places:
+ if (a_UUID.size() == 32)
+ {
+ a_UUID.insert(8, "-");
+ a_UUID.insert(13, "-");
+ a_UUID.insert(18, "-");
+ a_UUID.insert(23, "-");
+ }
return true;
}
@@ -330,6 +320,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
+/* In case we want to export this function to the plugin API later - don't forget to add the relevant INI configuration lines for DEFAULT_PROPERTIES_ADDRESS
+
+#define DEFAULT_PROPERTIES_ADDRESS "/session/minecraft/profile/%UUID%"
+
+// Gets the properties, such as skin, of a player based on their UUID via Mojang's API
+bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties);
+
bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties)
{
LOGD("Trying to get properties for user %s", a_UUID.c_str());
@@ -376,6 +373,7 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a
{
return false;
}
+
Json::Value root;
Json::Reader reader;
if (!reader.parse(Response, root, false))
@@ -387,7 +385,4 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a
a_Properties = root["properties"];
return true;
}
-
-
-
-
+*/
diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h
index 9f6dd60ca..9c2405315 100644
--- a/src/Protocol/Authenticator.h
+++ b/src/Protocol/Authenticator.h
@@ -85,13 +85,12 @@ private:
virtual void Execute(void) override;
/** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */
- bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response);
+ bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response);
- /** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */
- bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID);
-
- /** Gets the properties, such as skin, of a player based on their UUID via Mojang's API */
- bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties);
+ /** Returns true if the user authenticated okay, false on error
+ Sets the username, UUID, and properties (i.e. skin) fields
+ */
+ bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID, Json::Value & a_Properties);
};
--
cgit v1.2.3
From ad247735fdd28f9dec6c8e86507bc7e75e50e448 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 11:23:26 +0100
Subject: Function rename
---
src/Protocol/Authenticator.cpp | 4 ++--
src/Protocol/Authenticator.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 28df0f882..001bc29cf 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -190,7 +190,7 @@ void cAuthenticator::Execute(void)
-bool cAuthenticator::ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response)
+bool cAuthenticator::SecureGetFromAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response)
{
// Connect the socket:
cBlockingSslClientSocket Socket;
@@ -263,7 +263,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
Request += "\r\n";
AString Response;
- if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response))
+ if (!SecureGetFromAddress(gStarfieldCACert, m_Server, Request, Response))
{
return false;
}
diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h
index 9c2405315..244d94c0b 100644
--- a/src/Protocol/Authenticator.h
+++ b/src/Protocol/Authenticator.h
@@ -85,7 +85,7 @@ private:
virtual void Execute(void) override;
/** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */
- bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response);
+ bool SecureGetFromAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Request, AString & a_Response);
/** Returns true if the user authenticated okay, false on error
Sets the username, UUID, and properties (i.e. skin) fields
--
cgit v1.2.3
From 2189f37c20198a5889d5477aa4abcc116437861d Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 11:38:52 +0100
Subject: Resolved backwards compatibility issues
---
src/Bindings/Plugin.h | 2 +-
src/Bindings/PluginLua.cpp | 4 ++--
src/Bindings/PluginLua.h | 2 +-
src/Bindings/PluginManager.cpp | 4 ++--
src/Bindings/PluginManager.h | 2 +-
src/Entities/Entity.cpp | 2 +-
src/Mobs/IronGolem.h | 2 +-
7 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 160e83bde..5c933e095 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -63,7 +63,7 @@ public:
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
- virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) = 0;
+ virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 078e48111..e65329f23 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -575,14 +575,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper,
-bool cPluginLua::OnKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI)
+bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Victim, &a_TDI, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res);
if (res)
{
return true;
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index d1514a731..7a8a69b68 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -86,7 +86,7 @@ public:
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
- virtual bool OnKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI) override;
+ virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 1ebe8dd68..11d8bf4f1 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -562,14 +562,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
-bool cPluginManager::CallHookKilling(cEntity & a_Victim, TakeDamageInfo & a_TDI)
+bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
{
FIND_HOOK(HOOK_KILLING);
VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnKilling(a_Victim, a_TDI))
+ if ((*itr)->OnKilling(a_Victim, a_Killer, a_TDI))
{
return true;
}
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 7d63626bd..cd6287e64 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -180,7 +180,7 @@ public: // tolua_export
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
- bool CallHookKilling (cEntity & a_Victim, TakeDamageInfo & a_TDI);
+ bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 56ef22280..88900013d 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -528,7 +528,7 @@ void cEntity::KilledBy(TakeDamageInfo & a_TDI)
{
m_Health = 0;
- cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI);
+ cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI.Attacker, a_TDI);
if (m_Health > 0)
{
diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h
index 41c60438c..30f9bedff 100644
--- a/src/Mobs/IronGolem.h
+++ b/src/Mobs/IronGolem.h
@@ -19,7 +19,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
- // Iron golems do not drown
+ // Iron golems do not drown nor float
virtual void HandleAir(void) override {}
virtual void SetSwimState(cChunk & a_Chunk) override {}
} ;
--
cgit v1.2.3
From c5d00f3ec5acec908cd54b194a0042e0681764a5 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 12:05:09 +0100
Subject: Suggestions
---
src/Protocol/Protocol17x.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index d3b1cf946..6f46f8189 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -3016,8 +3016,11 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
Pkt.WriteString(a_Player.GetClientHandle()->GetUUID());
Pkt.WriteString(a_Player.GetName());
- Pkt.WriteVarInt(m_Client->GetProperties().size());
- for (Json::Value::iterator itr = m_Client->GetProperties().begin(); itr != m_Client->GetProperties().end(); ++itr)
+ const Json::Value & Properties = m_Client->GetProperties();
+ const Json::Value::const_iterator End = Properties.end();
+ Pkt.WriteVarInt(Properties.size());
+
+ for (Json::Value::iterator itr = Properties.begin(); itr != End; ++itr)
{
Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString());
Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString());
--
cgit v1.2.3
From 9194438fb552dc2f112535e2420d94de7af40e17 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 22:21:00 +0100
Subject: Fixed another redstone simulator crash
---
src/Simulator/IncrementalRedstoneSimulator.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index fb5b01e17..55c5cbd09 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -2101,6 +2101,13 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in
void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_SourceX, int a_SourceY, int a_SourceZ, cChunk * a_Chunk, bool a_IsFirstCall)
{
+ if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid
+ {
+ if ((a_Chunk == NULL) || !a_Chunk->IsValid())
+ {
+ return;
+ }
+ }
// TODO: on C++11 support, change both of these to llama functions pased to a std::remove_if
for (PoweredBlocksList::iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->end();)
--
cgit v1.2.3
From 960fcaa90c3ba4d57ff2205259471799e0418d12 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 22:22:00 +0100
Subject: Fixed a bug with buckets
* Additionally fixed cLineBlockTracer's EntryFace parameter when a block
was hit on the first iteration along the projected line
---
src/Items/ItemBucket.h | 2 +-
src/LineBlockTracer.cpp | 17 +++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h
index 84835c021..a733bda19 100644
--- a/src/Items/ItemBucket.h
+++ b/src/Items/ItemBucket.h
@@ -215,7 +215,7 @@ public:
} Callbacks;
cLineBlockTracer Tracer(*a_World, Callbacks);
- Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector());
+ Vector3d Start(a_Player->GetEyePosition());
Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5);
// cTracer::Trace returns true when whole line was traversed. By returning true when we hit something, we ensure that this never happens if liquid could be placed
diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp
index b03652bab..2395aa43e 100644
--- a/src/LineBlockTracer.cpp
+++ b/src/LineBlockTracer.cpp
@@ -203,6 +203,15 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk)
m_Callbacks->OnNoChunk();
return false;
}
+
+ // Move to next block
+ if (!MoveToNextBlock())
+ {
+ // We've reached the end
+ m_Callbacks->OnNoMoreHits();
+ return true;
+ }
+
if (a_Chunk->IsValid())
{
BLOCKTYPE BlockType;
@@ -225,14 +234,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk)
}
}
- // Move to next block
- if (!MoveToNextBlock())
- {
- // We've reached the end
- m_Callbacks->OnNoMoreHits();
- return true;
- }
-
// Update the current chunk
if (a_Chunk != NULL)
{
--
cgit v1.2.3
From 174906efca7f81655a57fa0a30c1158a16e77117 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Wed, 16 Jul 2014 22:22:45 +0100
Subject: Another fix for excessive food drain
---
src/Entities/Player.cpp | 9 +++++++++
src/Entities/Player.h | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index f131a1829..7b3827f42 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2141,6 +2141,8 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
{
return;
}
+
+ // If we have just teleported, apply no exhaustion
if (m_bIsTeleporting)
{
m_bIsTeleporting = false;
@@ -2152,6 +2154,13 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
{
return;
}
+
+ // Process exhaustion every two ticks as that is how frequently m_LastPos is updated
+ // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value
+ if (GetWorld()->GetWorldAge() % 2 != 0)
+ {
+ return;
+ }
// Calculate the distance travelled, update the last pos:
Vector3d Movement(GetPosition() - m_LastPos);
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 8f9b46e0f..b0fa01a7f 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -449,7 +449,7 @@ protected:
double m_FoodSaturationLevel;
/** Count-up to the healing or damaging action, based on m_FoodLevel */
- int m_FoodTickTimer;
+ int m_FoodTickTimer;
/** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */
double m_FoodExhaustionLevel;
--
cgit v1.2.3
From cd1e6f8ef028ea2a24e52190d305a62e6cfa62ab Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 17 Jul 2014 10:24:29 +0200
Subject: Fixed formatting for cWitherSkullEntity
---
src/Entities/WitherSkullEntity.cpp | 11 ++++++++++-
src/Entities/WitherSkullEntity.h | 5 +++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
index 03e36a3f4..a7e774bba 100644
--- a/src/Entities/WitherSkullEntity.cpp
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -1,3 +1,8 @@
+
+// WitherSkullEntity.cpp
+
+// Implements the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "WitherSkullEntity.h"
@@ -8,7 +13,7 @@
cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
-super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+ super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
{
SetSpeed(a_Speed);
}
@@ -38,3 +43,7 @@ void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_H
Destroy(true);
}
+
+
+
+
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index 85ba55d4d..8b3639802 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -1,6 +1,7 @@
-//
+
// WitherSkullEntity.h
-//
+
+// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
#pragma once
--
cgit v1.2.3
From 64c8b0d51b0ee8323dded6d22ac3b4754daa15d2 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 17 Jul 2014 10:51:44 +0200
Subject: Reformatted cItemPotionHandler.
---
src/BlockID.h | 3 +-
src/Items/ItemPotion.h | 124 ++++++++++++++++++++++++++++++-------------------
2 files changed, 79 insertions(+), 48 deletions(-)
diff --git a/src/BlockID.h b/src/BlockID.h
index e3567b6fc..ba05e9e1a 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -319,7 +319,8 @@ enum ENUM_ITEM_ID
E_ITEM_GHAST_TEAR = 370,
E_ITEM_GOLD_NUGGET = 371,
E_ITEM_NETHER_WART = 372,
- E_ITEM_POTIONS = 373,
+ E_ITEM_POTION = 373,
+ E_ITEM_POTIONS = 373, // OBSOLETE, use E_ITEM_POTION instead
E_ITEM_GLASS_BOTTLE = 374,
E_ITEM_SPIDER_EYE = 375,
E_ITEM_FERMENTED_SPIDER_EYE = 376,
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index b72499431..f3afbf99b 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -9,52 +9,67 @@ class cItemPotionHandler:
{
typedef cItemHandler super;
- int GetPotionName(short a_ItemDamage)
+public:
+
+ cItemPotionHandler():
+ super(E_ITEM_POTION)
+ {
+ }
+
+
+ /** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */
+ static int GetPotionParticleType(short a_ItemDamage)
{
- // First six bits (least significant)
- return a_ItemDamage & 0x3F;
+ // Lowest six bits
+ return (a_ItemDamage & 0x3f);
}
- cEntityEffect::eType GetEntityEffectType(short a_ItemDamage)
+
+ /** Translates the potion's damage value into the entity effect that the potion gives */
+ static cEntityEffect::eType GetEntityEffectType(short a_ItemDamage)
{
- // First four bits (least significant)
+ // Lowest four bits
// Potion effect bits are different from entity effect values
// For reference: http://minecraft.gamepedia.com/Data_values#.22Potion_effect.22_bits
- switch (a_ItemDamage & 0xF)
+ switch (a_ItemDamage & 0x0f)
{
- case 0x1: return cEntityEffect::effRegeneration;
- case 0x2: return cEntityEffect::effSpeed;
- case 0x3: return cEntityEffect::effFireResistance;
- case 0x4: return cEntityEffect::effPoison;
- case 0x5: return cEntityEffect::effInstantHealth;
- case 0x6: return cEntityEffect::effNightVision;
- case 0x8: return cEntityEffect::effWeakness;
- case 0x9: return cEntityEffect::effStrength;
- case 0xA: return cEntityEffect::effSlowness;
- case 0xC: return cEntityEffect::effInstantDamage;
- case 0xD: return cEntityEffect::effWaterBreathing;
- case 0xE: return cEntityEffect::effInvisibility;
+ case 0x01: return cEntityEffect::effRegeneration;
+ case 0x02: return cEntityEffect::effSpeed;
+ case 0x03: return cEntityEffect::effFireResistance;
+ case 0x04: return cEntityEffect::effPoison;
+ case 0x05: return cEntityEffect::effInstantHealth;
+ case 0x06: return cEntityEffect::effNightVision;
+ case 0x08: return cEntityEffect::effWeakness;
+ case 0x09: return cEntityEffect::effStrength;
+ case 0x0a: return cEntityEffect::effSlowness;
+ case 0x0c: return cEntityEffect::effInstantDamage;
+ case 0x0d: return cEntityEffect::effWaterBreathing;
+ case 0x0e: return cEntityEffect::effInvisibility;
// No effect potions
- case 0x0:
- case 0x7:
- case 0xB: // Will be potion of leaping in 1.8
- case 0xF:
+ case 0x00:
+ case 0x07:
+ case 0x0b: // Will be potion of leaping in 1.8
+ case 0x0f:
{
break;
}
}
-
return cEntityEffect::effNoEffect;
}
-
- short GetEntityEffectIntensity(short a_ItemDamage)
+
+
+ /** Retrieves the intensity level from the potion's damage value.
+ Returns 0 for level I potions, 1 for level II potions. */
+ static short GetEntityEffectIntensity(short a_ItemDamage)
{
- // Level II potion if fifth bit (from zero) is set
- return (a_ItemDamage & 0x20) ? 1 : 0;
+ // Level II potion if the fifth lowest bit is set
+ return ((a_ItemDamage & 0x20) != 0) ? 1 : 0;
}
- int GetEntityEffectDuration(short a_ItemDamage)
+
+ /** Returns the effect duration, in ticks, based on the potion's damage value */
+ static int GetEntityEffectDuration(short a_ItemDamage)
{
// Base duration in ticks
int base = 0;
@@ -88,42 +103,49 @@ class cItemPotionHandler:
}
}
- // If potion is level 2, half the duration. If not, stays the same
+ // If potion is level II, half the duration. If not, stays the same
TierCoeff = (GetEntityEffectIntensity(a_ItemDamage) > 0) ? 0.5 : 1;
// If potion is extended, multiply duration by 8/3. If not, stays the same
- // Extended potion if sixth bit (from zero) is set
- ExtCoeff = (a_ItemDamage & 0x40) ? (8.0/3.0) : 1;
+ // Extended potion if sixth lowest bit is set
+ ExtCoeff = (a_ItemDamage & 0x40) ? (8.0 / 3.0) : 1;
// If potion is splash potion, multiply duration by 3/4. If not, stays the same
- SplashCoeff = IsDrinkable(a_ItemDamage) ? 1 : 0.75;
+ SplashCoeff = IsPotionDrinkable(a_ItemDamage) ? 1 : 0.75;
- // For reference: http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit
- // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
- // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
+ // Ref.:
+ // http://minecraft.gamepedia.com/Data_values#.22Tier.22_bit
+ // http://minecraft.gamepedia.com/Data_values#.22Extended_duration.22_bit
+ // http://minecraft.gamepedia.com/Data_values#.22Splash_potion.22_bit
return (int)(base * TierCoeff * ExtCoeff * SplashCoeff);
}
-
-public:
- cItemPotionHandler():
- super(E_ITEM_POTIONS)
+
+
+ /** Returns true if the potion with the given damage is drinkable */
+ static bool IsPotionDrinkable(short a_ItemDamage)
{
+ // Drinkable potion if 13th lowest bit is set
+ // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return ((a_ItemDamage & 0x2000) != 0);
}
+
+ // cItemHandler overrides:
virtual bool IsDrinkable(short a_ItemDamage) override
{
- // Drinkable potion if 13th bit (from zero) is set
- // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
- return ((a_ItemDamage & 0x2000) != 0);
+ // Drinkable potion if 13th lowest bit is set
+ // Ref.: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return IsPotionDrinkable(a_ItemDamage);
}
+
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
{
short PotionDamage = a_Item.m_ItemDamage;
- // Only called when potion is a splash potion
- if (IsDrinkable(PotionDamage))
+ // Do not throw non-splash potions:
+ if (IsPotionDrinkable(PotionDamage))
{
return false;
}
@@ -131,8 +153,11 @@ public:
Vector3d Pos = a_Player->GetThrowStartPos();
Vector3d Speed = a_Player->GetLookVector() * 7;
- cSplashPotionEntity *Projectile = new cSplashPotionEntity(a_Player, Pos.x, Pos.y, Pos.z, &Speed, GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage), GetEntityEffectIntensity(PotionDamage)), GetPotionName(PotionDamage));
-
+ cSplashPotionEntity * Projectile = new cSplashPotionEntity(
+ a_Player, Pos.x, Pos.y, Pos.z, Speed,
+ GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage),
+ GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage)
+ );
if (Projectile == NULL)
{
return false;
@@ -151,11 +176,12 @@ public:
return true;
}
+
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
short PotionDamage = a_Item->m_ItemDamage;
- // Only called when potion is a drinkable potion
+ // Do not drink undrinkable potions:
if (!IsDrinkable(a_Item->m_ItemDamage))
{
return false;
@@ -167,3 +193,7 @@ public:
return true;
}
};
+
+
+
+
--
cgit v1.2.3
From 430d8b42a5b8889ff3c0bfaea84ede7e543e2b64 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 17 Jul 2014 11:07:10 +0200
Subject: Updated cPawn::KilledBy signature for custom death messages.
---
src/Entities/Pawn.cpp | 4 ++--
src/Entities/Pawn.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 840736f6a..fe6c24a7a 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -49,10 +49,10 @@ void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
-void cPawn::KilledBy(cEntity * a_Killer)
+void cPawn::KilledBy(TakeDamageInfo & a_TDI)
{
ClearEntityEffects();
- super::KilledBy(a_Killer);
+ super::KilledBy(a_TDI);
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 252ec5edb..63c7cfbb6 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -21,7 +21,7 @@ public:
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void KilledBy(cEntity * a_Killer) override;
+ virtual void KilledBy(TakeDamageInfo & a_TDI) override;
// tolua_begin
--
cgit v1.2.3
From 70f304a96b48de5c31993d9ee87c4b661e3c615c Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 17 Jul 2014 11:07:33 +0200
Subject: Fixed 3 MSVC warnings in SplashPotionEntity.
---
src/Entities/SplashPotionEntity.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 804026cc0..ed5afaf11 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -112,7 +112,7 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
- m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionParticleType);
+ m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType);
}
--
cgit v1.2.3
From db36f1a9fad7a79d489c36abd6140e7b48f7d413 Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Thu, 17 Jul 2014 13:54:28 +0100
Subject: Fixed crash with entities in unloaded chunks
* Fixes #1190
---
src/ChunkMap.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index b9bb39aa8..e2cf50314 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1736,7 +1736,9 @@ void cChunkMap::RemoveEntity(cEntity * a_Entity)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
- if ((Chunk == NULL) || !Chunk->IsValid())
+
+ // Even if a chunk is not valid, it may still contain entities such as players; make sure to remove them (#1190)
+ if (Chunk == NULL)
{
return;
}
--
cgit v1.2.3
From 3dd9649665e88e27298d93fd3c08b76ac5b0befa Mon Sep 17 00:00:00 2001
From: Tiger Wang
Date: Thu, 17 Jul 2014 14:32:52 +0100
Subject: Fixed mob knockback
* Fixes #901
---
src/Entities/Entity.cpp | 31 ++++++++-----------------------
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index c6dc1fca3..4a6de25b7 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -334,36 +334,21 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
{
- int KnockbackLevel = 0;
- if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW)
+ int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
+ if (KnockbackLevel < 1)
{
+ // We support punch on swords and vice versa! :)
KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
}
- else
- {
- KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback);
- }
- Vector3d additionalSpeed(0, 0, 0);
+ Vector3d AdditionalSpeed(0, 0, 0);
switch (KnockbackLevel)
{
- case 1:
- {
- additionalSpeed.Set(5, .3, 5);
- break;
- }
- case 2:
- {
- additionalSpeed.Set(8, .3, 8);
- break;
- }
- default:
- {
- additionalSpeed.Set(2, .3, 2);
- break;
- }
+ case 1: AdditionalSpeed.Set(5, 0.3, 5); break;
+ case 2: AdditionalSpeed.Set(8, 0.3, 8); break;
+ default: break;
}
- AddSpeed(a_TDI.Knockback * additionalSpeed);
+ AddSpeed(a_TDI.Knockback + AdditionalSpeed);
}
m_World->BroadcastEntityStatus(*this, esGenericHurt);
--
cgit v1.2.3
From 993fd14ddfc881cf5be951df77da0338124d68cc Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 17 Jul 2014 16:33:09 +0200
Subject: Fixed basic whitespace problems.
Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines.
---
src/AllocationPool.h | 8 +++--
src/BlockArea.cpp | 10 +++----
src/BlockArea.h | 4 +--
src/BlockID.cpp | 2 +-
src/BlockID.h | 4 +--
src/BlockTracer.h | 16 +++++-----
src/ChatColor.h | 2 +-
src/Chunk.cpp | 28 +++++++++---------
src/Chunk.h | 4 +--
src/ChunkDataCallback.h | 4 +--
src/ChunkDef.h | 26 ++++++++---------
src/ChunkMap.cpp | 6 ++--
src/ChunkMap.h | 6 ++--
src/ChunkSender.h | 10 +++----
src/ClientHandle.cpp | 20 ++++++-------
src/ClientHandle.h | 14 ++++-----
src/CraftingRecipes.cpp | 8 ++---
src/Cuboid.h | 4 +--
src/Defines.h | 2 +-
src/Globals.h | 10 +++----
src/Group.h | 26 ++++++++++-------
src/Inventory.h | 2 +-
src/Item.cpp | 14 ++++++++-
src/Item.h | 8 ++---
src/LightingThread.cpp | 2 +-
src/LightingThread.h | 8 ++---
src/Log.h | 4 +--
src/MCLogger.h | 9 +++---
src/Map.h | 20 ++++++-------
src/MapManager.h | 19 +++++-------
src/Matrix4.h | 2 +-
src/MobCensus.cpp | 2 +-
src/MobFamilyCollecter.h | 2 +-
src/MobProximityCounter.cpp | 2 +-
src/MobProximityCounter.h | 6 ++--
src/MobSpawner.cpp | 2 +-
src/MobSpawner.h | 4 +--
src/Noise.cpp | 50 +++++++++++++++----------------
src/Noise.h | 2 +-
src/Root.cpp | 8 ++---
src/Root.h | 28 ++++++++++--------
src/Scoreboard.cpp | 9 ++++--
src/Scoreboard.h | 23 +++++++--------
src/Server.h | 8 ++---
src/Statistics.h | 9 +++---
src/StringUtils.cpp | 71 ++++++++++++++++++++++-----------------------
src/StringUtils.h | 10 +------
src/Tracer.h | 2 +-
src/World.cpp | 10 +++----
src/World.h | 14 ++++-----
src/XMLParser.h | 36 +++++++++++------------
src/main.cpp | 4 +--
52 files changed, 306 insertions(+), 298 deletions(-)
diff --git a/src/AllocationPool.h b/src/AllocationPool.h
index 5d749a79e..3c9dbe8c9 100644
--- a/src/AllocationPool.h
+++ b/src/AllocationPool.h
@@ -61,7 +61,7 @@ class cListAllocationPool : public cAllocationPool
free (m_FreeList.front());
m_FreeList.pop_front();
}
- }
+ }
virtual T * Allocate() override
{
@@ -90,7 +90,7 @@ class cListAllocationPool : public cAllocationPool
}
virtual void Free(T * a_ptr) override
{
- if (a_ptr == NULL)
+ if (a_ptr == NULL)
{
return;
}
@@ -107,3 +107,7 @@ class cListAllocationPool : public cAllocationPool
std::list m_FreeList;
std::auto_ptr::cStarvationCallbacks> m_Callbacks;
};
+
+
+
+
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 0e4c42f0f..1df60b099 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -28,10 +28,10 @@ typedef void (CombinatorFunc)(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLE
// This wild construct allows us to pass a function argument and still have it inlined by the compiler :)
/// Merges two blocktypes and blockmetas of the specified sizes and offsets using the specified combinator function
-template
+template
void InternalMergeBlocks(
BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes,
- NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
+ NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas,
int a_SizeX, int a_SizeY, int a_SizeZ,
int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ,
int a_DstOffX, int a_DstOffY, int a_DstOffZ,
@@ -136,7 +136,7 @@ void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
return;
}
- // Air is always hollowed out
+ // Air is always hollowed out
if (a_SrcType == E_BLOCK_AIR)
{
a_DstType = E_BLOCK_AIR;
@@ -781,7 +781,7 @@ void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_Block
-void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
+void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
)
@@ -2226,7 +2226,7 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
m_Size.x, m_Size.y, m_Size.z
);
return;
- } // case msDifference
+ } // case msDifference
case cBlockArea::msMask:
{
diff --git a/src/BlockArea.h b/src/BlockArea.h
index 2bd26facd..a95ba7788 100644
--- a/src/BlockArea.h
+++ b/src/BlockArea.h
@@ -175,7 +175,7 @@ public:
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
/** Fills a cuboid inside the block area with the specified data */
- void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
+ void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
@@ -357,7 +357,7 @@ protected:
/** Sets the specified datatypes at the specified location. */
void RelSetData(
- int a_RelX, int a_RelY, int a_RelZ,
+ int a_RelX, int a_RelY, int a_RelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
);
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index 8edc51664..023172ca1 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -286,7 +286,7 @@ int StringToMobType(const AString & a_MobString)
{cMonster::mtMooshroom, "Mooshroom"},
{cMonster::mtSnowGolem, "SnowGolem"},
{cMonster::mtOcelot, "Ocelot"},
- {cMonster::mtIronGolem, "IronGolem"},
+ {cMonster::mtIronGolem, "IronGolem"},
{cMonster::mtVillager, "Villager"},
};
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
diff --git a/src/BlockID.h b/src/BlockID.h
index ba05e9e1a..43f911ce3 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -176,7 +176,7 @@ enum ENUM_BLOCK_ID
E_BLOCK_ACACIA_WOOD_STAIRS = 163,
E_BLOCK_DARK_OAK_WOOD_STAIRS = 164,
E_BLOCK_HAY_BALE = 170,
- E_BLOCK_CARPET = 171,
+ E_BLOCK_CARPET = 171,
E_BLOCK_HARDENED_CLAY = 172,
E_BLOCK_BLOCK_OF_COAL = 173,
E_BLOCK_PACKED_ICE = 174,
@@ -187,7 +187,7 @@ enum ENUM_BLOCK_ID
E_BLOCK_NUMBER_OF_TYPES, ///< Number of individual (different) blocktypes
E_BLOCK_MAX_TYPE_ID = E_BLOCK_NUMBER_OF_TYPES - 1, ///< Maximum BlockType number used
- // Synonym or ID compatibility
+ // Synonym or ID compatibility
E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION,
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
E_BLOCK_LOCKED_CHEST = E_BLOCK_STAINED_GLASS,
diff --git a/src/BlockTracer.h b/src/BlockTracer.h
index a18c8df4d..c569b4ec6 100644
--- a/src/BlockTracer.h
+++ b/src/BlockTracer.h
@@ -39,13 +39,13 @@ public:
/** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded
When this callback returns true, the tracing is aborted.
*/
- virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
- {
+ virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace)
+ {
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_EntryFace);
- return false;
+ return false;
}
/** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height)
@@ -54,8 +54,8 @@ public:
Note that some paths can go out of the world and come back again (parabola),
in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls
*/
- virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
- {
+ virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
+ {
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
@@ -68,12 +68,12 @@ public:
Note that some paths can go out of the world and come back again (parabola),
in such a case this callback is followed by further OnNextBlock() calls
*/
- virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
- {
+ virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ)
+ {
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
- return false;
+ return false;
}
/** Called when the path is sure not to hit any more blocks.
diff --git a/src/ChatColor.h b/src/ChatColor.h
index 643c4d5d8..2189fd395 100644
--- a/src/ChatColor.h
+++ b/src/ChatColor.h
@@ -27,7 +27,7 @@ public:
static const std::string Rose;
static const std::string LightPurple;
static const std::string Yellow;
- static const std::string White;
+ static const std::string White;
// Styles ( source: http://wiki.vg/Chat )
static const std::string Random;
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 8a249ea53..b88952fa0 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -62,7 +62,7 @@ sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_Bloc
// cChunk:
cChunk::cChunk(
- int a_ChunkX, int a_ChunkY, int a_ChunkZ,
+ int a_ChunkX, int a_ChunkY, int a_ChunkZ,
cChunkMap * a_ChunkMap, cWorld * a_World,
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP,
cAllocationPool & a_Pool
@@ -443,7 +443,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
{
currentPlayer = (*itr)->GetPlayer();
playerPositions.push_back(&(currentPlayer->GetPosition()));
- }
+ }
Vector3d currentPosition;
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
@@ -895,7 +895,7 @@ void cChunk::ApplyWeatherToTop()
SetBlock(X, Height, Z, E_BLOCK_ICE, 0);
}
else if (
- (m_World->IsDeepSnowEnabled()) &&
+ (m_World->IsDeepSnowEnabled()) &&
(
(TopBlock == E_BLOCK_RED_ROSE) ||
(TopBlock == E_BLOCK_YELLOW_FLOWER) ||
@@ -944,10 +944,10 @@ void cChunk::GrowMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_Bl
IsValid = IsValid && UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ + 1, BlockType[2], BlockMeta);
IsValid = IsValid && UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ - 1, BlockType[3], BlockMeta);
if (
- !IsValid ||
- (BlockType[0] == ProduceType) ||
- (BlockType[1] == ProduceType) ||
- (BlockType[2] == ProduceType) ||
+ !IsValid ||
+ (BlockType[0] == ProduceType) ||
+ (BlockType[1] == ProduceType) ||
+ (BlockType[2] == ProduceType) ||
(BlockType[3] == ProduceType)
)
{
@@ -1229,7 +1229,7 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
}
Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta);
return true;
-}
+}
@@ -2294,7 +2294,7 @@ bool cChunk::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceC
}
} // switch (BlockType)
- // The correct block entity is here,
+ // The correct block entity is here,
if (a_Callback.Item((cFurnaceEntity *)*itr))
{
return false;
@@ -2326,7 +2326,7 @@ bool cChunk::DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBl
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here
if (a_Callback.Item((cNoteEntity *)*itr))
{
return false;
@@ -2358,7 +2358,7 @@ bool cChunk::DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCom
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here,
if (a_Callback.Item((cCommandBlockEntity *)*itr))
{
return false;
@@ -2390,7 +2390,7 @@ bool cChunk::DoWithMobHeadAt(int a_BlockX, int a_BlockY, int a_BlockZ, cMobHeadC
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here,
if (a_Callback.Item((cMobHeadEntity *)*itr))
{
return false;
@@ -2422,7 +2422,7 @@ bool cChunk::DoWithFlowerPotAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFlower
return false;
}
- // The correct block entity is here,
+ // The correct block entity is here
if (a_Callback.Item((cFlowerPotEntity *)*itr))
{
return false;
@@ -2475,7 +2475,7 @@ bool cChunk::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_
BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
{
if (
- (a_RelX < 0) || (a_RelX >= Width) ||
+ (a_RelX < 0) || (a_RelX >= Width) ||
(a_RelY < 0) || (a_RelY >= Height) ||
(a_RelZ < 0) || (a_RelZ >= Width)
)
diff --git a/src/Chunk.h b/src/Chunk.h
index dfcfdab0f..f765bcdaf 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -87,7 +87,7 @@ public:
3. Mark the chunk as saved (MarkSaved() )
If anywhere inside this sequence another thread mmodifies the chunk, the chunk will not get marked as saved in MarkSaved()
*/
- void MarkSaving(void); // Marks the chunk as being saved.
+ void MarkSaving(void); // Marks the chunk as being saved.
void MarkSaved(void); // Marks the chunk as saved, if it didn't change from the last call to MarkSaving()
void MarkLoaded(void); // Marks the chunk as freshly loaded. Fails if the chunk is already valid
void MarkLoadFailed(void); // Marks the chunk as failed to load. Ignored is the chunk is already valid
@@ -97,7 +97,7 @@ public:
/** Sets all chunk data */
void SetAllData(
- const BLOCKTYPE * a_BlockTypes,
+ const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
const NIBBLETYPE * a_BlockSkyLight,
diff --git a/src/ChunkDataCallback.h b/src/ChunkDataCallback.h
index 0c8b1098f..53d44d038 100644
--- a/src/ChunkDataCallback.h
+++ b/src/ChunkDataCallback.h
@@ -25,8 +25,8 @@ public:
virtual ~cChunkDataCallback() {}
- /** Called before any other callbacks to inform of the current coords
- (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
+ /** Called before any other callbacks to inform of the current coords
+ (only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
If false is returned, the chunk is skipped.
*/
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; };
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index f89e16ed1..bd6387b74 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -22,8 +22,8 @@ It will help us when the new chunk format comes out and we need to patch everyth
#define ZERO_CHUNK_Y 0
// Used to smoothly convert to new axis ordering. One will be removed when deemed stable.
-#define AXIS_ORDER_YZX 1 // Original (1.1-)
-#define AXIS_ORDER_XZY 2 // New (1.2+)
+#define AXIS_ORDER_YZX 1 // Original (1.1-)
+#define AXIS_ORDER_XZY 2 // New (1.2+)
#define AXIS_ORDER AXIS_ORDER_XZY
@@ -72,7 +72,7 @@ public:
/// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column
typedef HEIGHTTYPE HeightMap[Width * Width];
- /** The type used for any biomemap operations and storage inside MCServer,
+ /** The type used for any biomemap operations and storage inside MCServer,
using MCServer biomes (need not correspond to client representation!)
idx = x + Width * z // Need to verify this with the protocol spec, currently unknown!
*/
@@ -148,17 +148,17 @@ public:
inline static Vector3i IndexToCoordinate( unsigned int index )
{
#if AXIS_ORDER == AXIS_ORDER_XZY
- return Vector3i( // 1.2
- index % cChunkDef::Width, // X
- index / (cChunkDef::Width * cChunkDef::Width), // Y
- (index / cChunkDef::Width) % cChunkDef::Width // Z
- );
+ return Vector3i( // 1.2
+ index % cChunkDef::Width, // X
+ index / (cChunkDef::Width * cChunkDef::Width), // Y
+ (index / cChunkDef::Width) % cChunkDef::Width // Z
+ );
#elif AXIS_ORDER == AXIS_ORDER_YZX
- return Vector3i( // 1.1
- index / (cChunkDef::Height * cChunkDef::Width), // X
- index % cChunkDef::Height, // Y
- (index / cChunkDef::Height) % cChunkDef::Width // Z
- );
+ return Vector3i( // 1.1
+ index / (cChunkDef::Height * cChunkDef::Width), // X
+ index % cChunkDef::Height, // Y
+ (index / cChunkDef::Height) % cChunkDef::Width // Z
+ );
#endif
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index b9bb39aa8..a83828bed 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -2711,7 +2711,7 @@ void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTi
// cChunkMap::cChunkLayer:
cChunkMap::cChunkLayer::cChunkLayer(
- int a_LayerX, int a_LayerZ,
+ int a_LayerX, int a_LayerZ,
cChunkMap * a_Parent,
cAllocationPool & a_Pool
)
@@ -2923,7 +2923,7 @@ int cChunkMap::cChunkLayer::GetNumChunksLoaded(void) const
NumChunks++;
}
} // for i - m_Chunks[]
- return NumChunks;
+ return NumChunks;
}
@@ -2994,7 +2994,7 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void)
void cChunkMap::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
cCSLock Lock(m_CSFastSetBlock);
- m_FastSetBlockQueue.push_back(sSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta));
+ m_FastSetBlockQueue.push_back(sSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta));
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index ef9b76e3f..0bbd3dab1 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -118,7 +118,7 @@ public:
If a_MarkDirty is set, the chunk is set as dirty (used after generating)
*/
void SetChunkData(
- int a_ChunkX, int a_ChunkZ,
+ int a_ChunkX, int a_ChunkZ,
const BLOCKTYPE * a_BlockTypes,
const NIBBLETYPE * a_BlockMeta,
const NIBBLETYPE * a_BlockLight,
@@ -361,7 +361,7 @@ private:
{
public:
cChunkLayer(
- int a_LayerX, int a_LayerZ,
+ int a_LayerX, int a_LayerZ,
cChunkMap * a_Parent,
cAllocationPool & a_Pool
);
@@ -384,7 +384,7 @@ private:
void UnloadUnusedChunks(void);
/** Collect a mob census, of all mobs, their megatype, their chunk and their distance o closest player */
- void CollectMobCensus(cMobCensus& a_ToFill);
+ void CollectMobCensus(cMobCensus& a_ToFill);
/** Try to Spawn Monsters inside all Chunks */
void SpawnMobs(cMobSpawner& a_MobSpawner);
diff --git a/src/ChunkSender.h b/src/ChunkSender.h
index 00565d7c3..095a99380 100644
--- a/src/ChunkSender.h
+++ b/src/ChunkSender.h
@@ -6,17 +6,17 @@
/*
The whole thing is a thread that runs in a loop, waiting for either:
"finished chunks" (ChunkReady()), or
- "chunks to send" (QueueSendChunkTo() )
-to come to a queue.
+ "chunks to send" (QueueSendChunkTo() )
+to come to a queue.
And once they do, it requests the chunk data and sends it all away, either
broadcasting (ChunkReady), or
sends to a specific client (QueueSendChunkTo)
Chunk data is queried using the cChunkDataCallback interface.
It is cached inside the ChunkSender object during the query and then processed after the query ends.
-Note that the data needs to be compressed only *after* the query finishes,
+Note that the data needs to be compressed only *after* the query finishes,
because the query callbacks run with ChunkMap's CS locked.
-A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient();
+A client may remove itself from all direct requests(QueueSendChunkTo()) by calling RemoveClient();
this ensures that the client's Send() won't be called anymore by ChunkSender.
Note that it may be called by world's BroadcastToChunk() if the client is still in the chunk.
*/
@@ -110,7 +110,7 @@ protected:
bool operator ==(const sSendChunk & a_Other)
{
return (
- (a_Other.m_ChunkX == m_ChunkX) &&
+ (a_Other.m_ChunkX == m_ChunkX) &&
(a_Other.m_ChunkY == m_ChunkY) &&
(a_Other.m_ChunkZ == m_ChunkZ) &&
(a_Other.m_Client == m_Client)
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index bd6fc1287..bf66e7db1 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -85,7 +85,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
{
m_Protocol = new cProtocolRecognizer(this);
- s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread
+ s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread
m_UniqueID = s_ClientCount;
cTimer t1;
@@ -531,7 +531,7 @@ void cClientHandle::HandlePing(void)
AString Reply;
const cServer & Server = *cRoot::Get()->GetServer();
- Printf(Reply, "%s%s%i%s%i",
+ Printf(Reply, "%s%s%i%s%i",
Server.GetDescription().c_str(),
cChatColor::Delimiter.c_str(),
Server.GetNumPlayers(),
@@ -1169,7 +1169,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1))
{
// Only compare ItemType, not meta (torches have different metas)
- // The -1 check is there because sometimes the client sends -1 instead of the held item
+ // The -1 check is there because sometimes the client sends -1 instead of the held item
// ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 )
LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)",
m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType
@@ -1390,7 +1390,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
Color = AString("@") + Color[2];
}
else
- {
+ {
Color.clear();
}
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
@@ -1449,7 +1449,7 @@ void cClientHandle::HandleAnimation(char a_Animation)
a_Animation--; // Offset by -1
break;
}
- case 5:
+ case 5:
case 6:
case 7:
{
@@ -1517,8 +1517,8 @@ void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, eClickAc
void cClientHandle::HandleUpdateSign(
- int a_BlockX, int a_BlockY, int a_BlockZ,
- const AString & a_Line1, const AString & a_Line2,
+ int a_BlockX, int a_BlockY, int a_BlockZ,
+ const AString & a_Line1, const AString & a_Line2,
const AString & a_Line3, const AString & a_Line4
)
{
@@ -1821,7 +1821,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void)
void cClientHandle::Tick(float a_Dt)
-{
+{
// Process received network data:
AString IncomingData;
{
@@ -1887,7 +1887,7 @@ void cClientHandle::Tick(float a_Dt)
void cClientHandle::ServerTick(float a_Dt)
-{
+{
// Process received network data:
AString IncomingData;
{
@@ -2345,7 +2345,7 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player)
return;
}
- LOGD("Spawning player \"%s\" on client \"%s\" @ %s",
+ LOGD("Spawning player \"%s\" on client \"%s\" @ %s",
a_Player.GetName().c_str(), GetPlayer()->GetName().c_str(), GetIPString().c_str()
);
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index ca39a01cd..d02b83cfe 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -48,7 +48,7 @@ class cStatManager;
class cClientHandle : // tolua_export
public cSocketThreads::cCallback
-{ // tolua_export
+{ // tolua_export
public:
#if defined(ANDROID_NDK)
@@ -64,9 +64,9 @@ public:
const AString & GetIPString(void) const { return m_IPString; }
- cPlayer * GetPlayer(void) { return m_Player; } // tolua_export
+ cPlayer * GetPlayer(void) { return m_Player; } // tolua_export
- const AString & GetUUID(void) const { return m_UUID; } // tolua_export
+ const AString & GetUUID(void) const { return m_UUID; } // tolua_export
void SetUUID(const AString & a_UUID) { m_UUID = a_UUID; }
const Json::Value & GetProperties(void) const { return m_Properties; }
@@ -246,8 +246,8 @@ public:
void HandleSteerVehicle (float Forward, float Sideways);
void HandleTabCompletion (const AString & a_Text);
void HandleUpdateSign (
- int a_BlockX, int a_BlockY, int a_BlockZ,
- const AString & a_Line1, const AString & a_Line2,
+ int a_BlockX, int a_BlockY, int a_BlockZ,
+ const AString & a_Line1, const AString & a_Line2,
const AString & a_Line3, const AString & a_Line4
);
void HandleUnmount (void);
@@ -338,7 +338,7 @@ private:
csAuthenticating, ///< The client has logged in, waiting for external authentication
csAuthenticated, ///< The client has been authenticated, will start streaming chunks in the next tick
csDownloadingWorld, ///< The client is waiting for chunks, we're waiting for the loader to provide and send them
- csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
+ csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
csPlaying, ///< Normal gameplay
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
@@ -408,7 +408,7 @@ private:
virtual bool DataReceived (const char * a_Data, size_t a_Size) override; // Data is received from the client
virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client
virtual void SocketClosed (void) override; // The socket has been closed for any reason
-}; // tolua_export
+}; // tolua_export
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index 0f1951351..a2ce359f3 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -135,7 +135,7 @@ void cCraftingGrid::ConsumeGrid(const cCraftingGrid & a_Grid)
{
if ((a_Grid.m_Width != m_Width) || (a_Grid.m_Height != m_Height))
{
- LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)",
+ LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)",
a_Grid.m_Width, a_Grid.m_Height, m_Width, m_Height
);
}
@@ -196,7 +196,7 @@ void cCraftingGrid::Dump(void)
#ifdef _DEBUG
int idx = x + m_Width * y;
#endif
- LOGD("Slot (%d, %d): Type %d, health %d, count %d",
+ LOGD("Slot (%d, %d): Type %d, health %d, count %d",
x, y, m_Items[idx].m_ItemType, m_Items[idx].m_ItemDamage, m_Items[idx].m_ItemCount
);
}
@@ -250,7 +250,7 @@ void cCraftingRecipe::Dump(void)
{
LOGD("Recipe ingredients:");
m_Ingredients.Dump();
- LOGD("Result: Type %d, health %d, count %d",
+ LOGD("Result: Type %d, health %d, count %d",
m_Result.m_ItemType, m_Result.m_ItemDamage, m_Result.m_ItemCount
);
}
@@ -665,7 +665,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
const cItem & Item = itrS->m_Item;
if (
- (itrS->x >= a_GridWidth) ||
+ (itrS->x >= a_GridWidth) ||
(itrS->y >= a_GridHeight) ||
(Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type?
(Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items
diff --git a/src/Cuboid.h b/src/Cuboid.h
index 3239c54fc..960af130b 100644
--- a/src/Cuboid.h
+++ b/src/Cuboid.h
@@ -38,7 +38,7 @@ public:
Assumes both cuboids are sorted. */
bool DoesIntersect(const cCuboid & a_Other) const;
- bool IsInside(const Vector3i & v) const
+ bool IsInside(const Vector3i & v) const
{
return (
(v.x >= p1.x) && (v.x <= p2.x) &&
@@ -47,7 +47,7 @@ public:
);
}
- bool IsInside(int a_X, int a_Y, int a_Z) const
+ bool IsInside(int a_X, int a_Y, int a_Z) const
{
return (
(a_X >= p1.x) && (a_X <= p2.x) &&
diff --git a/src/Defines.h b/src/Defines.h
index ee91ee596..ba2e8f504 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -512,7 +512,7 @@ inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, do
}
else
{
- a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
+ a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
}
a_Pitch = atan2(a_Y, r) * 180 / PI;
diff --git a/src/Globals.h b/src/Globals.h
index 998676fb1..62e0ad285 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -15,8 +15,8 @@
// Disable some warnings that we don't care about:
#pragma warning(disable:4100) // Unreferenced formal parameter
-
- // Useful warnings from warning level 4:
+
+ // Useful warnings from warning level 4:
#pragma warning(3 : 4127) // Conditional expression is constant
#pragma warning(3 : 4189) // Local variable is initialized but not referenced
#pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
@@ -58,8 +58,8 @@
// override is part of c++11
#if __cplusplus < 201103L
- #define override
- #endif
+ #define override
+ #endif
#define OBSOLETE __attribute__((deprecated))
@@ -145,7 +145,7 @@ class SizeChecker;
template
class SizeChecker
{
- T v;
+ T v;
};
template class SizeChecker;
diff --git a/src/Group.h b/src/Group.h
index 47088d50d..95063a987 100644
--- a/src/Group.h
+++ b/src/Group.h
@@ -5,18 +5,22 @@
-class cGroup // tolua_export
-{ // tolua_export
-public: // tolua_export
+// tolua_begin
+class cGroup
+{
+public:
+ // tolua_end
cGroup() {}
~cGroup() {}
- void SetName( const AString & a_Name ) { m_Name = a_Name; } // tolua_export
- const AString & GetName() const { return m_Name; } // tolua_export
- void SetColor( const AString & a_Color ) { m_Color = a_Color; } // tolua_export
- void AddCommand( const AString & a_Command ); // tolua_export
- void AddPermission( const AString & a_Permission ); // tolua_export
- void InheritFrom( cGroup* a_Group ); // tolua_export
+ // tolua_begin
+ void SetName( const AString & a_Name ) { m_Name = a_Name; }
+ const AString & GetName() const { return m_Name; }
+ void SetColor( const AString & a_Color ) { m_Color = a_Color; }
+ void AddCommand( const AString & a_Command );
+ void AddPermission( const AString & a_Permission );
+ void InheritFrom( cGroup* a_Group );
+ // tolua_end
typedef std::map< AString, bool > PermissionMap;
const PermissionMap & GetPermissions() const { return m_Permissions; }
@@ -26,7 +30,7 @@ public: // tolua_export
typedef std::map< AString, bool > CommandMap;
const CommandMap & GetCommands() const { return m_Commands; }
- const AString & GetColor() const { return m_Color; } // tolua_export
+ const AString & GetColor() const { return m_Color; } // tolua_export
typedef std::list< cGroup* > GroupList;
const GroupList & GetInherits() const { return m_Inherits; }
@@ -37,4 +41,4 @@ private:
PermissionMap m_Permissions;
CommandMap m_Commands;
GroupList m_Inherits;
-};// tolua_export
+}; // tolua_export
diff --git a/src/Inventory.h b/src/Inventory.h
index 39aef1538..e25fc4a8a 100644
--- a/src/Inventory.h
+++ b/src/Inventory.h
@@ -183,7 +183,7 @@ protected:
// cItemGrid::cListener override:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Item.cpp b/src/Item.cpp
index 56ceae0b7..b3ce32336 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -193,17 +193,29 @@ void cItem::FromJson(const Json::Value & a_Value)
bool cItem::IsEnchantable(short item)
{
if ((item >= 256) && (item <= 259))
+ {
return true;
+ }
if ((item >= 267) && (item <= 279))
+ {
return true;
- if ((item >= 283) && (item <= 286))
+ }
+ if ((item >= 283) && (item <= 286))
+ {
return true;
+ }
if ((item >= 290) && (item <= 294))
+ {
return true;
+ }
if ((item >= 298) && (item <= 317))
+ {
return true;
+ }
if ((item == 346) || (item == 359) || (item == 261))
+ {
return true;
+ }
return false;
}
diff --git a/src/Item.h b/src/Item.h
index acbc880dc..d8b9e78a0 100644
--- a/src/Item.h
+++ b/src/Item.h
@@ -150,7 +150,7 @@ public:
bool IsCustomNameEmpty(void) const { return (m_CustomName.empty()); }
- bool IsLoreEmpty(void) const { return (m_Lore.empty()); }
+ bool IsLoreEmpty(void) const { return (m_Lore.empty()); }
/** Returns a copy of this item with m_ItemCount set to 1. Useful to preserve enchantments etc. on stacked items */
cItem CopyOne(void) const;
@@ -184,14 +184,14 @@ public:
void FromJson(const Json::Value & a_Value);
/** Returns true if the specified item type is enchantable (as per 1.2.5 protocol requirements) */
- static bool IsEnchantable(short a_ItemType); // tolua_export
+ static bool IsEnchantable(short a_ItemType); // tolua_export
/** Returns the enchantability of the item. When the item hasn't a enchantability, it will returns 0 */
- int GetEnchantability(); // tolua_export
+ int GetEnchantability(); // tolua_export
/** Enchants the item using the specified number of XP levels.
Returns true if item enchanted, false if not. */
- bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export
+ bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export
// tolua_begin
diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp
index 33bc08467..403a3e097 100644
--- a/src/LightingThread.cpp
+++ b/src/LightingThread.cpp
@@ -495,7 +495,7 @@ void cLightingThread::CalcLight(NIBBLETYPE * a_Light)
void cLightingThread::CalcLightStep(
- NIBBLETYPE * a_Light,
+ NIBBLETYPE * a_Light,
int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
)
diff --git a/src/LightingThread.h b/src/LightingThread.h
index a484fcbed..f71d2cf1a 100644
--- a/src/LightingThread.h
+++ b/src/LightingThread.h
@@ -16,7 +16,7 @@ Lighting is calculated in a flood-fill fashion:
The seeds need two fast operations:
- Check if a block at [x, y, z] is already a seed
- Get the next seed in the row
-For that reason it is stored in two arrays, one stores a bool saying a seed is in that position,
+For that reason it is stored in two arrays, one stores a bool saying a seed is in that position,
the other is an array of seed coords, encoded as a single int.
Step 2 needs two separate storages for old seeds and new seeds, so there are two actual storages for that purpose,
their content is swapped after each full step-2-cycle.
@@ -82,7 +82,7 @@ protected:
cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter);
protected:
- virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
+ virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
{
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
@@ -157,7 +157,7 @@ protected:
/** Does one step in the light calculation - one seed propagation and seed recalculation */
void CalcLightStep(
- NIBBLETYPE * a_Light,
+ NIBBLETYPE * a_Light,
int a_NumSeedsIn, unsigned char * a_IsSeedIn, unsigned int * a_SeedIdxIn,
int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
);
@@ -166,7 +166,7 @@ protected:
void CompressLight(NIBBLETYPE * a_LightArray, NIBBLETYPE * a_ChunkLight);
inline void PropagateLight(
- NIBBLETYPE * a_Light,
+ NIBBLETYPE * a_Light,
unsigned int a_SrcIdx, unsigned int a_DstIdx,
int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut
)
diff --git a/src/Log.h b/src/Log.h
index d6a406154..dc88aa92f 100644
--- a/src/Log.h
+++ b/src/Log.h
@@ -6,7 +6,7 @@
class cLog
-{ // tolua_export
+{
private:
FILE * m_File;
static cLog * s_Log;
@@ -23,7 +23,7 @@ public:
void ClearLog();
static cLog* GetInstance();
};
-// tolua_end
+
diff --git a/src/MCLogger.h b/src/MCLogger.h
index 114210f63..aa3a52d02 100644
--- a/src/MCLogger.h
+++ b/src/MCLogger.h
@@ -10,7 +10,6 @@ class cLog;
-// tolua_begin
class cMCLogger
{
public:
@@ -27,9 +26,9 @@ public:
cMCLogger(void);
/** Creates a logger with the specified filename inside "logs" folder */
- cMCLogger(const AString & a_FileName); // tolua_export
+ cMCLogger(const AString & a_FileName);
- ~cMCLogger(); // tolua_export
+ ~cMCLogger();
void Log (const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0);
void Info (const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0);
@@ -37,7 +36,7 @@ public:
void Error(const char * a_Format, va_list a_ArgList) FORMATSTRING(2, 0);
/** Logs the simple text message at the specified log level. */
- void LogSimple(const char * a_Text, eLogLevel a_LogLevel = llRegular); // tolua_export
+ void LogSimple(const char * a_Text, eLogLevel a_LogLevel = llRegular);
static cMCLogger * GetInstance();
private:
@@ -63,7 +62,7 @@ private:
/// Common initialization for all constructors, creates a logfile with the specified name and assigns s_MCLogger to this
void InitLog(const AString & a_FileName);
-}; // tolua_export
+};
diff --git a/src/Map.h b/src/Map.h
index e23ca2c92..6bb2d62c6 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -29,13 +29,12 @@ class cMap;
/** Encapsulates a map decorator.
- *
- * A map decorator represents an object drawn on the map that can move freely.
- * (e.g. player trackers and item frame pointers)
- *
- * Excluding manually placed decorators,
- * decorators are automatically managed (allocated and freed) by their parent cMap instance.
- */
+A map decorator represents an object drawn on the map that can move freely.
+(e.g. player trackers and item frame pointers)
+
+Excluding manually placed decorators,
+decorators are automatically managed (allocated and freed) by their parent cMap instance.
+*/
class cMapDecorator
{
public:
@@ -194,10 +193,9 @@ public:
protected:
/** Encapsulates the state of a map client.
- *
- * In order to enhance performace, maps are streamed column-by-column to each client.
- * This structure stores the state of the stream.
- */
+ In order to enhance performace, maps are streamed column-by-column to each client.
+ This structure stores the state of the stream.
+ */
struct cMapClient
{
cClientHandle * m_Handle;
diff --git a/src/MapManager.h b/src/MapManager.h
index ceab8f126..3cd6c08cd 100644
--- a/src/MapManager.h
+++ b/src/MapManager.h
@@ -32,25 +32,22 @@ public:
cMapManager(cWorld * a_World);
/** Returns the map with the specified ID, NULL if out of range.
- *
- * WARNING: The returned map object is not thread safe.
- */
+ WARNING: The returned map object is not thread safe.
+ */
cMap * GetMapData(unsigned int a_ID);
/** Creates a new map. Returns NULL on error */
cMap * CreateMap(int a_CenterX, int a_CenterY, int a_Scale = 3);
/** Calls the callback for the map with the specified ID.
- *
- * Returns true if the map was found and the callback called, false if map not found.
- * Callback return ignored.
- */
+ Returns true if the map was found and the callback called, false if map not found.
+ Callback return value is ignored.
+ */
bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
- /** Calls the callback for each map.
- *
- * Returns true if all maps processed, false if the callback aborted by returning true.
- */
+ /** Calls the callback for each map.
+ Returns true if all maps processed, false if the callback aborted by returning true.
+ */
bool ForEachMap(cMapCallback & a_Callback);
size_t GetNumMaps(void) const; // tolua_export
diff --git a/src/Matrix4.h b/src/Matrix4.h
index 456677f0f..557057aca 100644
--- a/src/Matrix4.h
+++ b/src/Matrix4.h
@@ -104,7 +104,7 @@ public:
}
inline void Translate(const Vector3 & a_Pos)
- {
+ {
cell[3] += a_Pos.x;
cell[7] += a_Pos.y;
cell[11] += a_Pos.z;
diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp
index 23f74b59e..d5a341ef7 100644
--- a/src/MobCensus.cpp
+++ b/src/MobCensus.cpp
@@ -21,7 +21,7 @@ bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily)
{
const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
// but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319
- // MG TODO : code the correct count
+ // MG TODO : code the correct count
if ((GetCapMultiplier(a_MobFamily) * GetNumChunks()) / ratio >= m_MobFamilyCollecter.GetNumberOfCollectedMobs(a_MobFamily))
{
return false;
diff --git a/src/MobFamilyCollecter.h b/src/MobFamilyCollecter.h
index 6cef133b5..362814c8f 100644
--- a/src/MobFamilyCollecter.h
+++ b/src/MobFamilyCollecter.h
@@ -29,7 +29,7 @@ public :
// return the number of mobs for this family
int GetNumberOfCollectedMobs(cMonster::eFamily a_Family);
-protected :
+protected :
std::map > m_Mobs;
} ;
diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp
index ce20bf56b..35bf57380 100644
--- a/src/MobProximityCounter.cpp
+++ b/src/MobProximityCounter.cpp
@@ -8,7 +8,7 @@
void cMobProximityCounter::CollectMob(cEntity& a_Monster, cChunk& a_Chunk, double a_Distance)
{
-// LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance);
+ // LOGD("Collecting monster %s, with distance %f",a_Monster->GetClass(),a_Distance);
tMonsterToDistance::iterator it = m_MonsterToDistance.find(&a_Monster);
if (it == m_MonsterToDistance.end())
{
diff --git a/src/MobProximityCounter.h b/src/MobProximityCounter.h
index 79429eb60..cadfc48ae 100644
--- a/src/MobProximityCounter.h
+++ b/src/MobProximityCounter.h
@@ -27,11 +27,11 @@ protected :
cChunk& m_Chunk;
};
-public :
+public :
typedef std::map tMonsterToDistance;
typedef std::multimap tDistanceToMonster;
-protected :
+protected :
// this map is filled during collection phase, it will be later transformed into DistanceToMonster
tMonsterToDistance m_MonsterToDistance;
@@ -41,7 +41,7 @@ protected :
// this are the collected chunks. Used to determinate the number of elligible chunk for spawning.
std::set m_EligibleForSpawnChunks;
-protected :
+protected :
// transform monsterToDistance map (that was usefull for collecting) into distanceToMonster
// that will be usefull for picking up.
void convertMaps();
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index de8e01b8a..da3e7c406 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -91,7 +91,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
addIfAllowed(cMonster::mtCow, allowedMobs);
addIfAllowed(cMonster::mtChicken, allowedMobs);
addIfAllowed(cMonster::mtEnderman, allowedMobs);
- addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
+ addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
{
diff --git a/src/MobSpawner.h b/src/MobSpawner.h
index ea6636310..aa2935916 100644
--- a/src/MobSpawner.h
+++ b/src/MobSpawner.h
@@ -51,7 +51,7 @@ public :
typedef const std::set tSpawnedContainer;
tSpawnedContainer & getSpawned(void);
-protected :
+protected :
// return true if specified type of mob can spawn on specified block
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
@@ -62,7 +62,7 @@ protected :
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
void addIfAllowed(cMonster::eType toAdd, std::set & toAddIn);
-protected :
+protected :
cMonster::eFamily m_MonsterFamily;
std::set m_AllowedTypes;
bool m_NewPack;
diff --git a/src/Noise.cpp b/src/Noise.cpp
index fbd2a1800..e7b055ead 100644
--- a/src/Noise.cpp
+++ b/src/Noise.cpp
@@ -487,8 +487,8 @@ NOISE_DATATYPE cNoise::SmoothNoise1D(int a_X) const
NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const
{
- const int BaseX = FAST_FLOOR(a_X);
- const int BaseY = FAST_FLOOR(a_Y);
+ const int BaseX = FAST_FLOOR(a_X);
+ const int BaseY = FAST_FLOOR(a_Y);
const NOISE_DATATYPE points[4][4] =
{
@@ -515,28 +515,28 @@ NOISE_DATATYPE cNoise::CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) cons
NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOISE_DATATYPE a_Z) const
{
- const int BaseX = FAST_FLOOR(a_X);
- const int BaseY = FAST_FLOOR(a_Y);
- const int BaseZ = FAST_FLOOR(a_Z);
+ const int BaseX = FAST_FLOOR(a_X);
+ const int BaseY = FAST_FLOOR(a_Y);
+ const int BaseZ = FAST_FLOOR(a_Z);
- const NOISE_DATATYPE points1[4][4] = {
+ const NOISE_DATATYPE points1[4][4] = {
{ IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY, BaseZ - 1), IntNoise3D(BaseX, BaseY, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ - 1), },
};
- const NOISE_DATATYPE FracX = (a_X) - BaseX;
+ const NOISE_DATATYPE FracX = (a_X) - BaseX;
const NOISE_DATATYPE x1interp1 = CubicInterpolate( points1[0][0], points1[0][1], points1[0][2], points1[0][3], FracX );
const NOISE_DATATYPE x1interp2 = CubicInterpolate( points1[1][0], points1[1][1], points1[1][2], points1[1][3], FracX );
const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX );
const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX );
- const NOISE_DATATYPE points2[4][4] = {
- { IntNoise3D( BaseX-1, BaseY-1, BaseZ ), IntNoise3D( BaseX, BaseY-1, BaseZ ), IntNoise3D( BaseX+1, BaseY-1, BaseZ ), IntNoise3D( BaseX+2, BaseY-1, BaseZ ), },
- { IntNoise3D( BaseX-1, BaseY, BaseZ ), IntNoise3D( BaseX, BaseY, BaseZ ), IntNoise3D( BaseX+1, BaseY, BaseZ ), IntNoise3D( BaseX+2, BaseY, BaseZ ), },
- { IntNoise3D( BaseX-1, BaseY+1, BaseZ ), IntNoise3D( BaseX, BaseY+1, BaseZ ), IntNoise3D( BaseX+1, BaseY+1, BaseZ ), IntNoise3D( BaseX+2, BaseY+1, BaseZ ), },
- { IntNoise3D( BaseX-1, BaseY+2, BaseZ ), IntNoise3D( BaseX, BaseY+2, BaseZ ), IntNoise3D( BaseX+1, BaseY+2, BaseZ ), IntNoise3D( BaseX+2, BaseY+2, BaseZ ), },
+ const NOISE_DATATYPE points2[4][4] = {
+ { IntNoise3D(BaseX - 1, BaseY - 1, BaseZ), IntNoise3D(BaseX, BaseY - 1, BaseZ), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ), },
+ { IntNoise3D(BaseX - 1, BaseY, BaseZ), IntNoise3D(BaseX, BaseY, BaseZ), IntNoise3D(BaseX + 1, BaseY, BaseZ), IntNoise3D(BaseX + 2, BaseY, BaseZ), },
+ { IntNoise3D(BaseX - 1, BaseY + 1, BaseZ), IntNoise3D(BaseX, BaseY + 1, BaseZ), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ), },
+ { IntNoise3D(BaseX - 1, BaseY + 2, BaseZ), IntNoise3D(BaseX, BaseY + 2, BaseZ), IntNoise3D(BaseX + 1, BaseY + 2, BaseZ), IntNoise3D(BaseX + 2, BaseY + 2, BaseZ), },
};
const NOISE_DATATYPE x2interp1 = CubicInterpolate( points2[0][0], points2[0][1], points2[0][2], points2[0][3], FracX );
@@ -544,11 +544,11 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX );
const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX );
- const NOISE_DATATYPE points3[4][4] = {
- { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), },
- { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), },
- { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), },
- { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), },
+ const NOISE_DATATYPE points3[4][4] = {
+ { IntNoise3D( BaseX-1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), },
+ { IntNoise3D( BaseX-1, BaseY, BaseZ+1 ), IntNoise3D( BaseX, BaseY, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), },
+ { IntNoise3D( BaseX-1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), },
+ { IntNoise3D( BaseX-1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+1 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ + 1), },
};
const NOISE_DATATYPE x3interp1 = CubicInterpolate( points3[0][0], points3[0][1], points3[0][2], points3[0][3], FracX );
@@ -556,11 +556,11 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX );
const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX );
- const NOISE_DATATYPE points4[4][4] = {
- { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), },
- { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), },
- { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), },
- { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), },
+ const NOISE_DATATYPE points4[4][4] = {
+ { IntNoise3D( BaseX-1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2 ), },
+ { IntNoise3D( BaseX-1, BaseY, BaseZ+2 ), IntNoise3D( BaseX, BaseY, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY, BaseZ+2 ), },
+ { IntNoise3D( BaseX-1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2 ), },
+ { IntNoise3D( BaseX-1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+1, BaseY+2, BaseZ+2 ), IntNoise3D( BaseX+2, BaseY+2, BaseZ+2 ), },
};
const NOISE_DATATYPE x4interp1 = CubicInterpolate( points4[0][0], points4[0][1], points4[0][2], points4[0][3], FracX );
@@ -568,13 +568,13 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const NOISE_DATATYPE x4interp3 = CubicInterpolate( points4[2][0], points4[2][1], points4[2][2], points4[2][3], FracX );
const NOISE_DATATYPE x4interp4 = CubicInterpolate( points4[3][0], points4[3][1], points4[3][2], points4[3][3], FracX );
- const NOISE_DATATYPE FracY = (a_Y) - BaseY;
+ const NOISE_DATATYPE FracY = (a_Y) - BaseY;
const NOISE_DATATYPE yinterp1 = CubicInterpolate( x1interp1, x1interp2, x1interp3, x1interp4, FracY );
const NOISE_DATATYPE yinterp2 = CubicInterpolate( x2interp1, x2interp2, x2interp3, x2interp4, FracY );
const NOISE_DATATYPE yinterp3 = CubicInterpolate( x3interp1, x3interp2, x3interp3, x3interp4, FracY );
const NOISE_DATATYPE yinterp4 = CubicInterpolate( x4interp1, x4interp2, x4interp3, x4interp4, FracY );
- const NOISE_DATATYPE FracZ = (a_Z) - BaseZ;
+ const NOISE_DATATYPE FracZ = (a_Z) - BaseZ;
return CubicInterpolate( yinterp1, yinterp2, yinterp3, yinterp4, FracZ );
}
@@ -631,7 +631,7 @@ void cCubicNoise::Generate2D(
Cell.InitWorkRnds(FloorX[0], FloorY[0]);
#ifdef _DEBUG
- // Statistics on the noise-space coords:
+ // Statistics on the noise-space coords:
if (NumSameX == 1)
{
m_NumSingleX++;
diff --git a/src/Noise.h b/src/Noise.h
index 83af0cf08..014e43239 100644
--- a/src/Noise.h
+++ b/src/Noise.h
@@ -100,7 +100,7 @@ protected:
cNoise m_Noise; // Used for integral rnd values
#ifdef _DEBUG
- // Statistics on the noise-space coords:
+ // Statistics on the noise-space coords:
static int m_NumSingleX;
static int m_NumSingleXY;
static int m_NumSingleY;
diff --git a/src/Root.cpp b/src/Root.cpp
index ec1351ef1..235a1b108 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -84,7 +84,7 @@ void cRoot::InputThread(void * a_Params)
AString Command;
std::getline(std::cin, Command);
if (!Command.empty())
- {
+ {
self.ExecuteConsoleCommand(TrimString(Command), Output);
}
}
@@ -194,7 +194,7 @@ void cRoot::Start(void)
#if !defined(ANDROID_NDK)
LOGD("Starting InputThread...");
m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" );
- m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread
+ m_InputThread->Start( false ); // We should NOT wait? Otherwise we can't stop the server from other threads than the input thread
#endif
long long finishmseconds = Time.GetNowTime();
@@ -687,7 +687,7 @@ int cRoot::GetVirtualRAMUsage(void)
&t_info_count
))
{
- return (int)(t_info.virtual_size / 1024);
+ return (int)(t_info.virtual_size / 1024);
}
return -1;
#else
@@ -739,7 +739,7 @@ int cRoot::GetPhysicalRAMUsage(void)
&t_info_count
))
{
- return (int)(t_info.resident_size / 1024);
+ return (int)(t_info.resident_size / 1024);
}
return -1;
#else
diff --git a/src/Root.h b/src/Root.h
index 4a3c205d3..acd3e9754 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -36,20 +36,24 @@ namespace Json
/// The root of the object hierarchy
-class cRoot // tolua_export
-{ // tolua_export
+// tolua_begin
+class cRoot
+{
public:
- static cRoot * Get() { return s_Root; } // tolua_export
+ static cRoot * Get() { return s_Root; }
+ // tolua_end
cRoot(void);
~cRoot();
void Start(void);
- cServer * GetServer(void) { return m_Server; } // tolua_export
- cWorld * GetDefaultWorld(void); // tolua_export
- cWorld * GetWorld(const AString & a_WorldName); // tolua_export
- cWorld * CreateAndInitializeWorld(const AString & a_WorldName); // tolua_export
+ // tolua_begin
+ cServer * GetServer(void) { return m_Server; }
+ cWorld * GetDefaultWorld(void);
+ cWorld * GetWorld(const AString & a_WorldName);
+ cWorld * CreateAndInitializeWorld(const AString & a_WorldName);
+ // tolua_end
/// Calls the callback for each world; returns true if the callback didn't abort (return true)
bool ForEachWorld(cWorldListCallback & a_Callback); // >> Exported in ManualBindings <<
@@ -106,13 +110,13 @@ public:
void SaveAllChunks(void); // tolua_export
/// Reloads all the groups
- void ReloadGroups(void); // tolua_export
+ void ReloadGroups(void); // tolua_export
/// Calls the callback for each player in all worlds
- bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+ bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
/// Finds a player from a partial or complete player name and calls the callback - case-insensitive
- bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+ bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// tolua_begin
@@ -202,8 +206,8 @@ private:
static void InputThread(void* a_Params);
- static cRoot* s_Root;
-}; // tolua_export
+ static cRoot* s_Root;
+}; // tolua_export
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index 250f63aa9..8695f0fb7 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -197,15 +197,18 @@ void cObjective::SendTo(cClientHandle & a_Client)
-cTeam::cTeam(const AString & a_Name, const AString & a_DisplayName,
- const AString & a_Prefix, const AString & a_Suffix)
+cTeam::cTeam(
+ const AString & a_Name, const AString & a_DisplayName,
+ const AString & a_Prefix, const AString & a_Suffix
+)
: m_AllowsFriendlyFire(true)
, m_CanSeeFriendlyInvisible(false)
, m_DisplayName(a_DisplayName)
, m_Name(a_Name)
, m_Prefix(a_Prefix)
, m_Suffix(a_Suffix)
-{}
+{
+}
diff --git a/src/Scoreboard.h b/src/Scoreboard.h
index 1e1973a10..5f91535f8 100644
--- a/src/Scoreboard.h
+++ b/src/Scoreboard.h
@@ -259,25 +259,22 @@ public:
/** Send this scoreboard to the specified client */
void SendTo(cClientHandle & a_Client);
- cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
+ cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
- /** Execute callback for each objective with the specified type
- *
- * Returns true if all objectives processed, false if the callback aborted by returning true.
- */
+ /** Execute callback for each objective with the specified type
+ Returns true if all objectives processed, false if the callback aborted by returning true.
+ */
bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback);
/** Execute callback for each objective.
- *
- * Returns true if all objectives have been processed, false if the callback aborted by returning true.
- */
- bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp
+ Returns true if all objectives have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp
/** Execute callback for each team.
- *
- * Returns true if all teams have been processed, false if the callback aborted by returning true.
- */
- bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp
+ Returns true if all teams have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp
void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);
diff --git a/src/Server.h b/src/Server.h
index cf5fa524f..a6b7297e8 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -50,10 +50,10 @@ namespace Json
-class cServer // tolua_export
+class cServer // tolua_export
: public cListenThread::cCallback
-{ // tolua_export
-public: // tolua_export
+{ // tolua_export
+public: // tolua_export
virtual ~cServer() {}
bool InitServer(cIniFile & a_SettingsIni);
@@ -149,7 +149,7 @@ private:
virtual void Execute(void);
- public:
+ public:
cNotifyWriteThread(void);
~cNotifyWriteThread();
diff --git a/src/Statistics.h b/src/Statistics.h
index f37f32e1e..49750e8c0 100644
--- a/src/Statistics.h
+++ b/src/Statistics.h
@@ -62,7 +62,7 @@ enum eStatistic
statDistDove,
statDistMinecart,
statDistBoat,
- statDistPig,
+ statDistPig,
statDistHorse,
statJumps,
statItemsDropped,
@@ -143,10 +143,9 @@ public:
/** Reset everything. */
void Reset();
- /** Increment the specified stat.
- *
- * Returns the new value.
- */
+ /** Increments the specified stat.
+ Returns the new value.
+ */
StatValue AddValue(const eStatistic a_Stat, const StatValue a_Delta = 1);
// tolua_end
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 7488a3073..9429157a9 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -233,13 +233,13 @@ AString & StrToLower(AString & s)
int NoCaseCompare(const AString & s1, const AString & s2)
{
#ifdef _MSC_VER
- // MSVC has stricmp that compares case-insensitive:
- return _stricmp(s1.c_str(), s2.c_str());
- #else
- // Do it the hard way:
- AString s1Copy(s1);
- AString s2Copy(s2);
- return StrToUpper(s1Copy).compare(StrToUpper(s2Copy));
+ // MSVC has stricmp that compares case-insensitive:
+ return _stricmp(s1.c_str(), s2.c_str());
+ #else
+ // Do it the hard way:
+ AString s1Copy(s1);
+ AString s2Copy(s2);
+ return StrToUpper(s1Copy).compare(StrToUpper(s2Copy));
#endif // else _MSC_VER
}
@@ -346,9 +346,9 @@ AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UT
/*
Notice from the original file:
* Copyright 2001-2004 Unicode, Inc.
-*
+*
* Disclaimer
-*
+*
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
@@ -356,9 +356,9 @@ Notice from the original file:
* purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media
* within 90 days of receipt.
-*
+*
* Limitations on Rights to Redistribute This Code
-*
+*
* Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form
@@ -378,13 +378,13 @@ Notice from the original file:
static const char trailingBytesForUTF8[256] =
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
};
@@ -394,7 +394,7 @@ static const char trailingBytesForUTF8[256] =
static const unsigned int offsetsFromUTF8[6] =
{
- 0x00000000UL, 0x00003080UL, 0x000E2080UL,
+ 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL
};
@@ -502,22 +502,21 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a
return a_UTF16;
}
-/* ---------------------------------------------------------------------
-
- Note A.
- The fall-through switches in UTF-8 reading code save a
- temp variable, some decrements & conditionals. The switches
- are equivalent to the following loop:
- {
- int tmpBytesToRead = extraBytesToRead+1;
- do {
- ch += *source++;
- --tmpBytesToRead;
- if (tmpBytesToRead) ch <<= 6;
- } while (tmpBytesToRead > 0);
- }
-
- ---------------------------------------------------------------------
+/*
+---------------------------------------------------------------------
+Note A.
+The fall-through switches in UTF-8 reading code save a
+temp variable, some decrements & conditionals. The switches
+are equivalent to the following loop:
+{
+ int tmpBytesToRead = extraBytesToRead+1;
+ do {
+ ch += *source++;
+ --tmpBytesToRead;
+ if (tmpBytesToRead) ch <<= 6;
+ } while (tmpBytesToRead > 0);
+}
+---------------------------------------------------------------------
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -761,7 +760,7 @@ AString Base64Decode(const AString & a_Base64String)
{
switch (o & 7)
{
- case 0: res[o >> 3] |= (c << 2); break;
+ case 0: res[o >> 3] |= (c << 2); break;
case 6: res[o >> 3] |= (c >> 4); res[(o >> 3) + 1] |= (c << 4); break;
case 4: res[o >> 3] |= (c >> 2); res[(o >> 3) + 1] |= (c << 6); break;
case 2: res[o >> 3] |= c; break;
diff --git a/src/StringUtils.h b/src/StringUtils.h
index 87b574a34..30b9904d1 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -6,10 +6,7 @@
-#ifndef STRINGUTILS_H_INCLUDED
-#define STRINGUTILS_H_INCLUDED
-
-
+#pragma once
#include
@@ -101,8 +98,3 @@ extern void SetBEInt(char * a_Mem, Int32 a_Value);
-#endif // STRINGUTILS_H_INCLUDED
-
-
-
-
diff --git a/src/Tracer.h b/src/Tracer.h
index bdb080f0d..4d932e460 100644
--- a/src/Tracer.h
+++ b/src/Tracer.h
@@ -53,7 +53,7 @@ private:
/// Calculates where on the block a collision occured, if it does occur
/// Returns 0 if no intersection occured
/// Returns 1 if an intersection occured at a single point
- /// Returns 2 if the line segment lies in the plane being checked
+ /// Returns 2 if the line segment lies in the plane being checked
int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal );
/// Determines which face on the block a collision occured, if it does occur
diff --git a/src/World.cpp b/src/World.cpp
index f7279e9bc..b3284942a 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -99,7 +99,7 @@ protected:
{
for (;;)
{
- LOG("" SIZE_T_FMT " chunks to load, %d chunks to generate",
+ LOG("" SIZE_T_FMT " chunks to load, %d chunks to generate",
m_World->GetStorage().GetLoadQueueLength(),
m_World->GetGenerator().GetQueueLength()
);
@@ -2226,7 +2226,7 @@ void cWorld::SetChunkData(
const NIBBLETYPE * a_BlockSkyLight,
const cChunkDef::HeightMap * a_HeightMap,
const cChunkDef::BiomeMap * a_BiomeMap,
- cEntityList & a_Entities,
+ cEntityList & a_Entities,
cBlockEntityList & a_BlockEntities,
bool a_MarkDirty
)
@@ -2242,7 +2242,7 @@ void cWorld::SetChunkData(
}
m_ChunkMap->SetChunkData(
- a_ChunkX, a_ChunkZ,
+ a_ChunkX, a_ChunkZ,
a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight,
a_HeightMap, *Biomes,
a_BlockEntities,
@@ -2872,7 +2872,7 @@ void cWorld::RemoveEntity(cEntity * a_Entity)
unsigned int cWorld::GetNumPlayers(void)
{
cCSLock Lock(m_CSPlayers);
- return m_Players.size();
+ return m_Players.size();
}
*/
@@ -2920,7 +2920,7 @@ void cWorld::TickQueuedBlocks(void)
}
else
{
- m_BlockTickQueue.push_back(Block); // Keep the block in the queue
+ m_BlockTickQueue.push_back(Block); // Keep the block in the queue
}
} // for itr - m_BlockTickQueueCopy[]
}
diff --git a/src/World.h b/src/World.h
index 5bb0e640f..a3b152a80 100644
--- a/src/World.h
+++ b/src/World.h
@@ -140,7 +140,7 @@ public:
int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
virtual Int64 GetWorldAge (void) const override { return m_WorldAge; }
- virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; }
+ virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; }
void SetTicksUntilWeatherChange(int a_WeatherInterval)
{
@@ -301,10 +301,10 @@ public:
bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
/** Finds a player from a partial or complete player name and calls the callback - case-insensitive */
- bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
+ bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
- cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
+ cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player
@@ -365,10 +365,10 @@ public:
bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines() */
- bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
+ bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
/** Sets the command block command. Returns true if command changed. */
- bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
+ bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
/** Is the trapdoor open? Returns false if there is no trapdoor at the specified coords. */
bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
@@ -377,10 +377,10 @@ public:
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export
/** Regenerate the given chunk: */
- void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
+ void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Generates the given chunk, if not already generated */
- void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
+ void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL);
diff --git a/src/XMLParser.h b/src/XMLParser.h
index f492d1a5d..28fa05579 100644
--- a/src/XMLParser.h
+++ b/src/XMLParser.h
@@ -61,7 +61,7 @@ protected:
// It uses templates to remove the virtual function call penalty (both size and speed) for each callback
/* Usage:
-1, Declare a subclass:
+1, Declare a subclass:
class CMyParser : public CExpatImpl
2, Declare handlers that you want in that subclass:
void CMyParser::OnEndElement(const XML_Char * iTagName);
@@ -318,7 +318,7 @@ protected:
void EnableEndDoctypeDeclHandler (bool fEnable = true)
{
assert (m_p != NULL);
- XML_SetEndDoctypeDeclHandler (m_p,
+ XML_SetEndDoctypeDeclHandler (m_p,
fEnable ? EndDoctypeDeclHandler : NULL);
}
@@ -336,7 +336,7 @@ public:
// @cmember Get last error
- enum XML_Error GetErrorCode ()
+ enum XML_Error GetErrorCode ()
{
assert (m_p != NULL);
return XML_GetErrorCode (m_p);
@@ -344,7 +344,7 @@ public:
// @cmember Get the current byte index
- long GetCurrentByteIndex ()
+ long GetCurrentByteIndex ()
{
assert (m_p != NULL);
return XML_GetCurrentByteIndex (m_p);
@@ -352,7 +352,7 @@ public:
// @cmember Get the current line number
- int GetCurrentLineNumber ()
+ int GetCurrentLineNumber ()
{
assert (m_p != NULL);
return XML_GetCurrentLineNumber (m_p);
@@ -360,7 +360,7 @@ public:
// @cmember Get the current column number
- int GetCurrentColumnNumber ()
+ int GetCurrentColumnNumber ()
{
assert (m_p != NULL);
return XML_GetCurrentColumnNumber (m_p);
@@ -368,7 +368,7 @@ public:
// @cmember Get the current byte count
- int GetCurrentByteCount ()
+ int GetCurrentByteCount ()
{
assert (m_p != NULL);
return XML_GetCurrentByteCount (m_p);
@@ -384,7 +384,7 @@ public:
// @cmember Get last error string
- const XML_LChar *GetErrorString ()
+ const XML_LChar *GetErrorString ()
{
return XML_ErrorString (GetErrorCode ());
}
@@ -411,7 +411,7 @@ public:
// @cmember Get last error string
- static const XML_LChar *GetErrorString (enum XML_Error nError)
+ static const XML_LChar *GetErrorString (enum XML_Error nError)
{
return XML_ErrorString (nError);
}
@@ -443,7 +443,7 @@ public:
// @cmember Processing instruction handler
- void OnProcessingInstruction (const XML_Char *pszTarget,
+ void OnProcessingInstruction (const XML_Char *pszTarget,
const XML_Char *pszData)
{
return;
@@ -495,7 +495,7 @@ public:
// @cmember Start namespace declaration handler
- void OnStartNamespaceDecl (const XML_Char *pszPrefix,
+ void OnStartNamespaceDecl (const XML_Char *pszPrefix,
const XML_Char *pszURI)
{
return;
@@ -518,7 +518,7 @@ public:
// @cmember Start DOCTYPE declaration handler
- void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
+ void OnStartDoctypeDecl (const XML_Char *pszDoctypeName,
const XML_Char *pszSysID, const XML_Char *pszPubID,
bool fHasInternalSubset)
{
@@ -607,7 +607,7 @@ protected:
// @cmember Default wrapper
- static void __cdecl DefaultHandler (void *pUserData,
+ static void __cdecl DefaultHandler (void *pUserData,
const XML_Char *pszData, int nLength)
{
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
@@ -616,12 +616,12 @@ protected:
// @cmember External entity ref wrapper
- static int __cdecl ExternalEntityRefHandler (void *pUserData,
- const XML_Char *pszContext, const XML_Char *pszBase,
+ static int __cdecl ExternalEntityRefHandler (void *pUserData,
+ const XML_Char *pszContext, const XML_Char *pszBase,
const XML_Char *pszSystemID, const XML_Char *pszPublicID)
{
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- return pThis ->OnExternalEntityRef (pszContext,
+ return pThis ->OnExternalEntityRef (pszContext,
pszBase, pszSystemID, pszPublicID) ? 1 : 0;
}
@@ -660,12 +660,12 @@ protected:
// @cmember Start Doctype declaration wrapper
static void __cdecl StartDoctypeDeclHandler (
- void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID,
+ void *pUserData, const XML_Char *pszDoctypeName, const XML_Char *pszSysID,
const XML_Char *pszPubID, int nHasInternalSubset
)
{
_T *pThis = static_cast <_T *> ((CExpatImpl <_T> *) pUserData);
- pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID,
+ pThis ->OnStartDoctypeDecl (pszDoctypeName, pszSysID,
pszPubID, nHasInternalSubset != 0);
}
diff --git a/src/main.cpp b/src/main.cpp
index 6925d9ff1..c8ff31f07 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -49,7 +49,7 @@ bool g_ShouldLogCommOut;
-void NonCtrlHandler(int a_Signal)
+void NonCtrlHandler(int a_Signal)
{
LOGD("Terminate event raised from std::signal");
g_TERMINATE_EVENT_RAISED = true;
@@ -277,7 +277,7 @@ int main( int argc, char **argv )
try
#endif
{
- cRoot Root;
+ cRoot Root;
Root.Start();
}
#if !defined(ANDROID_NDK)
--
cgit v1.2.3
From 7fff12bfacbb4bef1c02cea0ec10fdc9a6fb64e4 Mon Sep 17 00:00:00 2001
From: madmaxoft
Date: Thu, 17 Jul 2014 19:13:23 +0200
Subject: Fixed spaces around single-line comments.
There should be at least two spaces in front and one space after //-style comments.
---
src/BlockID.h | 2 +-
src/BlockInfo.h | 2 +-
src/Chunk.cpp | 22 +++++++++++-----------
src/Chunk.h | 1 -
src/ChunkDef.h | 4 ++--
src/ChunkMap.cpp | 23 ++++++++++++-----------
src/ClientHandle.cpp | 24 +++++++++++++-----------
src/ClientHandle.h | 16 +++++++++-------
src/CraftingRecipes.cpp | 2 +-
src/Defines.h | 2 +-
src/FurnaceRecipe.cpp | 8 ++++----
src/Globals.h | 22 +++++++++++-----------
src/GroupManager.cpp | 2 +-
src/Inventory.cpp | 4 ++--
src/Log.cpp | 4 ++--
src/Map.h | 2 +-
src/MapManager.h | 6 +++---
src/Matrix4.h | 2 +-
src/MobCensus.cpp | 2 +-
src/MobFamilyCollecter.h | 2 +-
src/MobProximityCounter.cpp | 4 ++--
src/MobSpawner.h | 2 +-
src/Root.cpp | 6 +++---
src/Scoreboard.h | 6 +++---
src/Server.cpp | 6 +++---
src/Server.h | 6 +++---
src/Statistics.h | 4 ++--
src/Tracer.cpp | 24 ++++++++++++------------
src/Vector3.h | 2 +-
src/WebAdmin.cpp | 2 +-
src/WebAdmin.h | 8 ++++----
src/World.cpp | 32 +++++++++++++++-----------------
src/World.h | 8 ++++----
src/main.cpp | 18 +++++++++---------
34 files changed, 141 insertions(+), 139 deletions(-)
diff --git a/src/BlockID.h b/src/BlockID.h
index 43f911ce3..4246c0bc9 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -171,7 +171,7 @@ enum ENUM_BLOCK_ID
E_BLOCK_DROPPER = 158,
E_BLOCK_STAINED_CLAY = 159,
E_BLOCK_STAINED_GLASS_PANE = 160,
- E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
+ E_BLOCK_NEW_LEAVES = 161, // Acacia and Dark Oak IDs in Minecraft 1.7.x
E_BLOCK_NEW_LOG = 162,
E_BLOCK_ACACIA_WOOD_STAIRS = 163,
E_BLOCK_DARK_OAK_WOOD_STAIRS = 164,
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index d6d4e7430..ed6fd4754 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -81,7 +81,7 @@ protected:
/** Initializes the specified BlockInfo structures with block-specific values. */
static void Initialize(cBlockInfoArray & a_BlockInfos);
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index b88952fa0..2d8ff7714 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -448,7 +448,7 @@ void cChunk::CollectMobCensus(cMobCensus& toFill)
Vector3d currentPosition;
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- //LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
+ // LOGD("Counting entity #%i (%s)", (*itr)->GetUniqueID(), (*itr)->GetClass());
if ((*itr)->IsMob())
{
cMonster& Monster = (cMonster&)(**itr);
@@ -698,13 +698,13 @@ void cChunk::ProcessQueuedSetBlocks(void)
{
if (itr->m_Tick <= CurrTick)
{
- if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified
+ if (itr->m_PreviousType != E_BLOCK_AIR) // PreviousType defaults to 0 if not specified
{
if (GetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ) == itr->m_PreviousType)
{
// Current world age is bigger than/equal to target world age - delay time reached AND
// Previous block type was the same as current block type (to prevent duplication)
- SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client
+ SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client
itr = m_SetBlockQueue.erase(itr);
LOGD("Successfully set queued block - previous and current types matched");
}
@@ -810,7 +810,7 @@ void cChunk::TickBlocks(void)
if (m_BlockTickY > cChunkDef::GetHeight(m_HeightMap, m_BlockTickX, m_BlockTickZ))
{
- continue; // It's all air up here
+ continue; // It's all air up here
}
cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ));
@@ -1530,11 +1530,11 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType);
- if ( // Queue block to be sent only if ...
- a_SendToClients && // ... we are told to do so AND ...
+ if ( // Queue block to be sent only if ...
+ a_SendToClients && // ... we are told to do so AND ...
(
- (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
- !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics:
+ (OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
+ !( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics:
((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water
@@ -1727,7 +1727,7 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
{
if ((!(*itr)->IsPickup()) && (!(*itr)->IsProjectile()))
{
- continue; // Only pickups and projectiles
+ continue; // Only pickups and projectiles can be picked up
}
float DiffX = (float)((*itr)->GetPosX() - PosX );
float DiffY = (float)((*itr)->GetPosY() - PosY );
@@ -2152,7 +2152,7 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
{
continue;
}
- if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers
+ if (((*itr)->GetBlockType() != E_BLOCK_CHEST) && ((*itr)->GetBlockType() != E_BLOCK_TRAPPED_CHEST)) // Trapped chests use normal chests' handlers
{
// There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out
return false;
@@ -2481,7 +2481,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
)
{
ASSERT(!"GetBlock(x, y, z) out of bounds!");
- return 0; // Clip
+ return 0; // Clip
}
return m_ChunkData.GetBlock(a_RelX, a_RelY, a_RelZ);
diff --git a/src/Chunk.h b/src/Chunk.h
index f765bcdaf..2e2895c6e 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -274,7 +274,6 @@ public:
void UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z); // [x, y, z] in world block coords
- void CalculateLighting(); // Recalculate right now
void CalculateHeightmap(const BLOCKTYPE * a_BlockTypes);
// Broadcast various packets to all clients of this chunk:
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index bd6387b74..334f8a6b9 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -138,9 +138,9 @@ public:
{
#if AXIS_ORDER == AXIS_ORDER_XZY
// For some reason, NOT using the Horner schema is faster. Weird.
- return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 is XZY
+ return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 uses XZY
#elif AXIS_ORDER == AXIS_ORDER_YZX
- return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 is YZX
+ return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 uses YZX
#endif
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index a83828bed..de2016015 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -20,7 +20,7 @@
#include "Entities/Pickup.h"
#ifndef _WIN32
- #include // abs
+ #include // abs
#endif
#include "zlib/zlib.h"
@@ -33,14 +33,15 @@
////////////////////////////////////////////////////////////////////////////////
// cChunkMap:
-cChunkMap::cChunkMap(cWorld * a_World )
- : m_World( a_World ),
+cChunkMap::cChunkMap(cWorld * a_World) :
+ m_World(a_World),
m_Pool(
new cListAllocationPool(
std::auto_ptr::cStarvationCallbacks>(
- new cStarvationCallbacks())
+ new cStarvationCallbacks()
)
)
+ )
{
}
@@ -1873,15 +1874,15 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
default:
{
- if (m_World->GetTickRandomNumber(100) <= 25) // 25% chance of pickups
+ if (m_World->GetTickRandomNumber(100) <= 25) // 25% chance of pickups
{
cItems Drops;
cBlockHandler * Handler = BlockHandler(Block);
- Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc.
+ Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc.
m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
}
- else if ((m_World->GetTNTShrapnelLevel() > slNone) && (m_World->GetTickRandomNumber(100) < 20)) // 20% chance of flinging stuff around
+ else if ((m_World->GetTNTShrapnelLevel() > slNone) && (m_World->GetTickRandomNumber(100) < 20)) // 20% chance of flinging stuff around
{
if (!cBlockInfo::FullyOccupiesVoxel(Block))
{
@@ -1921,7 +1922,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
{
if (a_Entity->IsPickup())
{
- if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned)
+ if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned)
{
return false;
}
@@ -1930,7 +1931,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
Vector3d EntityPos = a_Entity->GetPosition();
cBoundingBox bbEntity(EntityPos, a_Entity->GetWidth() / 2, a_Entity->GetHeight());
- if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround
+ if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround
{
return false;
}
@@ -1953,7 +1954,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
else if (FinalDamage < 0)
FinalDamage = 0;
- if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
+ if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
{
a_Entity->TakeDamage(dtExplosion, NULL, (int)FinalDamage, 0);
}
@@ -2733,7 +2734,7 @@ cChunkMap::cChunkLayer::~cChunkLayer()
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i)
{
delete m_Chunks[i];
- m_Chunks[i] = NULL; // // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data
+ m_Chunks[i] = NULL; // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data
} // for i - m_Chunks[]
}
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index bf66e7db1..afa99008a 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -589,7 +589,7 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel
void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed)
{
- UNUSED(FlyingSpeed); // Ignore the client values for these
+ UNUSED(FlyingSpeed); // Ignore the client values for these
UNUSED(WalkingSpeed);
m_Player->SetCanFly(a_CanFly);
@@ -668,7 +668,7 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString
if (HasPluginChannel(a_Channel))
{
SendPluginMessage("UNREGISTER", a_Channel);
- return; // Can't register again if already taken - kinda defeats the point of plugin messaging!
+ return; // Can't register again if already taken - kinda defeats the point of plugin messaging!
}
RegisterPluginChannels(BreakApartPluginChannels(a_Message));
@@ -842,7 +842,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
}
if (
- ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored
+ ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored
((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
(Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
(Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6))
@@ -926,7 +926,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
// A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
return;
}
- m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected
+ m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected
return;
}
@@ -989,7 +989,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
int pY = a_BlockY;
int pZ = a_BlockZ;
- AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false)
+ AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false)
cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ));
if (Handler->IsClickedThrough())
@@ -1083,7 +1083,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
void cClientHandle::FinishDigAnimation()
{
- if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet
+ if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet
{
return;
}
@@ -1441,23 +1441,25 @@ void cClientHandle::HandleAnimation(char a_Animation)
// Because the animation ID sent to servers by clients are different to those sent back, we need this
switch (a_Animation)
{
- case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1
+ case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1
case 1:
case 2:
case 3:
{
- a_Animation--; // Offset by -1
+ a_Animation--; // Offset by -1
break;
}
case 5:
case 6:
case 7:
{
- a_Animation -= 2; // Offset by -2
+ a_Animation -= 2; // Offset by -2
break;
}
- default: // Anything else is the same
+ default: // Anything else is the same
+ {
break;
+ }
}
m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this);
@@ -2473,7 +2475,7 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
-void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts
+void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts
{
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index d02b83cfe..539e24ef6 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -123,7 +123,7 @@ public:
void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType);
void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage);
- void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
+ void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); // tolua_export
void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes);
void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChat (const cCompositeChat & a_Message);
@@ -271,15 +271,14 @@ public:
private:
- /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
- void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
-
/** The type used for storing the names of registered plugin channels. */
typedef std::set cChannels;
- int m_ViewDistance; // Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 )
+ /** Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) */
+ int m_ViewDistance;
- static const int GENERATEDISTANCE = 2; // Server generates this many chunks AHEAD of player sight. 2 is the minimum, since foliage is generated 1 step behind chunk terrain generation
+ /** Server generates this many chunks AHEAD of player sight. */
+ static const int GENERATEDISTANCE = 2;
AString m_IPString;
@@ -317,7 +316,7 @@ private:
int m_PingID;
long long m_PingStartTime;
long long m_LastPingTime;
- static const unsigned short PING_TIME_MS = 1000; //minecraft sends 1 per 20 ticks (1 second or every 1000 ms)
+ static const unsigned short PING_TIME_MS = 1000; // Vanilla sends 1 per 20 ticks (1 second or every 1000 ms)
// Values required for block dig animation
int m_BlockDigAnimStage; // Current stage of the animation; -1 if not digging
@@ -374,6 +373,9 @@ private:
cChannels m_PluginChannels;
+ /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
+ void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
+
/** Returns true if the rate block interactions is within a reasonable limit (bot protection) */
bool CheckBlockInteractionsRate(void);
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index a2ce359f3..e9946160f 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -838,7 +838,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe
case E_ITEM_GOLD_NUGGET: a_Recipe->m_Result.m_FireworkItem.m_Type = 2; break;
case E_ITEM_FEATHER: a_Recipe->m_Result.m_FireworkItem.m_Type = 4; break;
case E_ITEM_HEAD: a_Recipe->m_Result.m_FireworkItem.m_Type = 3; break;
- default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins
+ default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins
}
}
diff --git a/src/Defines.h b/src/Defines.h
index ba2e8f504..877970ab8 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -22,7 +22,7 @@ typedef std::vector cSlotNums;
/// Experience Orb setup
enum
{
- //open to suggestion on naming convention here :)
+ // Open to suggestion on naming convention here :)
MAX_EXPERIENCE_ORB_SIZE = 2000
} ;
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index 8add9610c..cf29e227f 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -107,7 +107,7 @@ void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, int a_LineNum)
{
// Fuel
int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
- AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
+ AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang)
if (
!ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID
@@ -133,7 +133,7 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, int a_LineNum)
{
int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0;
int OItemID = 0, OItemCount = 0, OItemHealth = 0;
- AString::size_type BeginPos = 0; // Begin at start of line
+ AString::size_type BeginPos = 0; // Begin at start of line
if (
!ReadMandatoryNumber(BeginPos, ":", a_Line, a_LineNum, IItemID) || // Read item ID
@@ -193,7 +193,7 @@ bool cFurnaceRecipe::ReadMandatoryNumber(AString::size_type & a_Begin, const ASt
}
a_Value = atoi(a_Text.substr(a_Begin, End - a_Begin).c_str());
- a_Begin = End + 1; // Jump over delimiter
+ a_Begin = End + 1; // Jump over delimiter
return true;
}
@@ -236,7 +236,7 @@ bool cFurnaceRecipe::ReadOptionalNumbers(AString::size_type & a_Begin, const ASt
}
a_ValueTwo = atoi(a_Text.substr(Begin, End - Begin).c_str());
- a_Begin = End + 1; // Jump over delimiter
+ a_Begin = End + 1; // Jump over delimiter
return true;
}
else
diff --git a/src/Globals.h b/src/Globals.h
index 62e0ad285..9b2f25f36 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -14,18 +14,18 @@
#pragma warning(disable:4481)
// Disable some warnings that we don't care about:
- #pragma warning(disable:4100) // Unreferenced formal parameter
+ #pragma warning(disable:4100) // Unreferenced formal parameter
// Useful warnings from warning level 4:
- #pragma warning(3 : 4127) // Conditional expression is constant
- #pragma warning(3 : 4189) // Local variable is initialized but not referenced
- #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
- #pragma warning(3 : 4310) // Cast truncates constant value
- #pragma warning(3 : 4389) // Signed/unsigned mismatch
- #pragma warning(3 : 4505) // Unreferenced local function has been removed
- #pragma warning(3 : 4701) // Potentially unitialized local variable used
- #pragma warning(3 : 4702) // Unreachable code
- #pragma warning(3 : 4706) // Assignment within conditional expression
+ #pragma warning(3 : 4127) // Conditional expression is constant
+ #pragma warning(3 : 4189) // Local variable is initialized but not referenced
+ #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
+ #pragma warning(3 : 4310) // Cast truncates constant value
+ #pragma warning(3 : 4389) // Signed/unsigned mismatch
+ #pragma warning(3 : 4505) // Unreferenced local function has been removed
+ #pragma warning(3 : 4701) // Potentially unitialized local variable used
+ #pragma warning(3 : 4702) // Unreachable code
+ #pragma warning(3 : 4706) // Assignment within conditional expression
// Disabling this warning, because we know what we're doing when we're doing this:
#pragma warning(disable: 4355) // 'this' used in initializer list
@@ -34,7 +34,7 @@
#pragma warning(disable: 4512) // 'class': assignment operator could not be generated - reported for each class that has a reference-type member
// 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places
- // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data
+ // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data
#define OBSOLETE __declspec(deprecated)
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 11e62c223..ffba68200 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -145,7 +145,7 @@ bool cGroupManager::LoadGroups()
AString KeyName = IniFile.GetKeyName(i);
cGroup * Group = GetGroup(KeyName.c_str());
- Group->ClearPermission(); // Needed in case the groups are reloaded.
+ Group->ClearPermission(); // Needed in case the groups are reloaded.
LOGD("Loading group %s", KeyName.c_str());
diff --git a/src/Inventory.cpp b/src/Inventory.cpp
index bce882c88..38d3c886d 100644
--- a/src/Inventory.cpp
+++ b/src/Inventory.cpp
@@ -493,7 +493,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
if( NumFree >= a_Item.m_ItemCount )
{
- //printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
+ // printf("1. Adding %i items ( free: %i )\n", a_Item.m_ItemCount, NumFree );
m_Slots[i + a_Offset].m_ItemCount += a_Item.m_ItemCount;
a_Item.m_ItemCount = 0;
a_bChangedSlots[i + a_Offset] = true;
@@ -501,7 +501,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
}
else
{
- //printf("2. Adding %i items\n", NumFree );
+ // printf("2. Adding %i items\n", NumFree );
m_Slots[i + a_Offset].m_ItemCount += (char)NumFree;
a_Item.m_ItemCount -= (char)NumFree;
a_bChangedSlots[i + a_Offset] = true;
diff --git a/src/Log.cpp b/src/Log.cpp
index a7be04b1a..d96e3e9e4 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -130,9 +130,9 @@ void cLog::Log(const char * a_Format, va_list argList)
// Print to console:
#if defined(ANDROID_NDK)
- //__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
+ // __android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList);
__android_log_print(ANDROID_LOG_ERROR, "MCServer", "%s", Line.c_str() );
- //CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
+ // CallJavaFunction_Void_String(g_JavaThread, "AddToLog", Line );
#else
printf("%s", Line.c_str());
#endif
diff --git a/src/Map.h b/src/Map.h
index 6bb2d62c6..fe324a5e7 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -256,7 +256,7 @@ private:
friend class cMapSerializer;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/MapManager.h b/src/MapManager.h
index 3cd6c08cd..a40ec2630 100644
--- a/src/MapManager.h
+++ b/src/MapManager.h
@@ -43,14 +43,14 @@ public:
Returns true if the map was found and the callback called, false if map not found.
Callback return value is ignored.
*/
- bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
+ bool DoWithMap(int a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
/** Calls the callback for each map.
Returns true if all maps processed, false if the callback aborted by returning true.
*/
bool ForEachMap(cMapCallback & a_Callback);
- size_t GetNumMaps(void) const; // tolua_export
+ size_t GetNumMaps(void) const; // tolua_export
/** Loads the map data from the disk */
void LoadMapData(void);
@@ -69,7 +69,7 @@ private:
cWorld * m_World;
-}; // tolua_export
+}; // tolua_export
diff --git a/src/Matrix4.h b/src/Matrix4.h
index 557057aca..081847b9f 100644
--- a/src/Matrix4.h
+++ b/src/Matrix4.h
@@ -3,7 +3,7 @@
-#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
+#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC)
#include
diff --git a/src/MobCensus.cpp b/src/MobCensus.cpp
index d5a341ef7..4109aff07 100644
--- a/src/MobCensus.cpp
+++ b/src/MobCensus.cpp
@@ -19,7 +19,7 @@ void cMobCensus::CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Dis
bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily)
{
- const int ratio = 319; // this should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
+ const int ratio = 319; // This should be 256 as we are only supposed to take account from chunks that are in 17x17 from a player
// but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19*19) / (17*17) = 319
// MG TODO : code the correct count
if ((GetCapMultiplier(a_MobFamily) * GetNumChunks()) / ratio >= m_MobFamilyCollecter.GetNumberOfCollectedMobs(a_MobFamily))
diff --git a/src/MobFamilyCollecter.h b/src/MobFamilyCollecter.h
index 362814c8f..c4324bd68 100644
--- a/src/MobFamilyCollecter.h
+++ b/src/MobFamilyCollecter.h
@@ -4,7 +4,7 @@
#include