From e50423991e56f1edb0954f2db066acd1f27b4ed7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 21:57:23 +0200 Subject: [PATCH 001/280] 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); From 885a50d77a26eea6619de681bf6ee746e79308cd Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 22:57:13 +0200 Subject: [PATCH 002/280] 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()) { From b45e85a6784861e225c7a4ecfd7838a6d32c7875 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 22:57:27 +0200 Subject: [PATCH 003/280] 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()) From a1fd0b0335a5b19af29a4862f4d0ac39bec6887f Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 16 Jun 2014 23:41:23 +0200 Subject: [PATCH 004/280] 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()) { From d89f03b90c60c2aaae3f937f5b84dc3c8f2f6ad1 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 12:43:45 +0200 Subject: [PATCH 005/280] 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) ); From 37de63895f029342b92923d08585aa8f4fdae2ea Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 12:45:12 +0200 Subject: [PATCH 006/280] 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(); From 8928310fd8308c583609edd1cb111276ffe79f8e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Jun 2014 13:27:04 +0200 Subject: [PATCH 007/280] 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) { From ce06ec1632ffb15243e2270ed31632e8d3566f39 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 17 Jun 2014 13:33:41 +0200 Subject: [PATCH 008/280] 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) From 15ae4ce23371ec6bc1b1f61f4dd7c4ffbd1adf64 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Jun 2014 14:55:15 +0200 Subject: [PATCH 009/280] 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 From 008a6ce311d3020927d5ef4b0d53905df48bcae5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Jun 2014 16:19:31 +0200 Subject: [PATCH 010/280] 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 From c1692a2e3be114c2807fdaaea0fa4fcd3d4bbc5d Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 00:16:33 -0700 Subject: [PATCH 011/280] 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 From 87b1bfaf2aa62bf600293d11d0b3c73cfe9f9e33 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 00:17:49 -0700 Subject: [PATCH 012/280] 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" From aa7b3f33b939e6a43af713549e7b3bf28d0f5ab5 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 19:09:33 -0700 Subject: [PATCH 013/280] 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 From 90145a95144a7895fe9a2d7bb1d5c7a192f3a0ad Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 20:02:39 -0700 Subject: [PATCH 014/280] 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); } From 481f05b011230cba42901df939306b803bd670b6 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 21:48:20 -0700 Subject: [PATCH 015/280] 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); From 2123173202554487386697625342b7ba21744960 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 21:55:23 -0700 Subject: [PATCH 016/280] 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. } } From a9a4c9c6b25438aaebdeef03c323e9aa4a0348c2 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 6 Jun 2014 23:05:29 -0700 Subject: [PATCH 017/280] 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)); } From e98ffccd80ae05d09b40d5edd407428515b14406 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 00:54:03 -0700 Subject: [PATCH 018/280] 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 From 615152eb8c6c88083f7b9eac57ec07147f34a6d6 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 02:02:20 -0700 Subject: [PATCH 019/280] 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)); } From 1eb04a48ee3ec4114adc4334e6fbcc7561834025 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 13:45:00 -0700 Subject: [PATCH 020/280] 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; + } +}; From 2185c72c2ca2d66b238d7d3234c173bd820d32ac Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 16:32:37 -0700 Subject: [PATCH 021/280] 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; + } +}; From 8eceaf9b0cadbc253e46cdcbf8a7b5e8d6070846 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 18:48:33 -0700 Subject: [PATCH 022/280] 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; } From 5803094d7d0a852568c45c450dc2cc52e6c7d681 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 19:58:41 -0700 Subject: [PATCH 023/280] 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 From 58f35af6e71f11844b9c6c1d1ebd2d7390439cca Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 21:56:01 -0700 Subject: [PATCH 024/280] Added splash potion functionality --- src/Entities/EntityEffects.h | 4 ++ src/Entities/Pawn.cpp | 7 ++-- src/Entities/ProjectileEntity.cpp | 2 - src/Entities/SplashPotionEntity.cpp | 60 +++++++++++++++++++++++++---- src/Entities/SplashPotionEntity.h | 30 +++++++++++++-- src/Items/ItemPotion.h | 36 ++++++++++++++++- 6 files changed, 123 insertions(+), 16 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); - - // TODO: Apply potion effect to entity and others nearby - + 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 + + 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(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; } From 73cea7065db458da7704917788ac80b75e042d6e Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 03:27:22 -0700 Subject: [PATCH 025/280] 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; From a1a8b7c0eee2189dfc129eb366edb43a315749f9 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 16:31:18 -0700 Subject: [PATCH 026/280] 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), From 3766ac96d77329c679d01d1ab1a846384acab42f Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 17:06:15 -0700 Subject: [PATCH 027/280] 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 From 68011a004a83adc793f0df563cc924c5a2b7dddc Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 17:17:30 -0700 Subject: [PATCH 028/280] 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; From 52abd90a28736ca07ad4b2df1259f3b54fd74c9d Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 18:14:34 -0700 Subject: [PATCH 029/280] 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; From 2574573c883fd7b5d19d19547f34dbef6820b5ea Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 18:44:20 -0700 Subject: [PATCH 030/280] 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; From 814cdca054bec5826b491f6d9d9867ce587d2def Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 21:51:55 -0700 Subject: [PATCH 031/280] 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! From 71b4c4949087860ab9962d6545a0ad2eb9c0ee5a Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 11 Jun 2014 16:21:47 -0700 Subject: [PATCH 032/280] 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; } ; From 5b2b6e06150b6299d1e19374be092c0858b0e3a8 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 12 Jun 2014 19:50:02 -0700 Subject: [PATCH 033/280] 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; From 045ae2ef2c0d72b4902fa5151aad095823da9300 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 09:49:42 +0200 Subject: [PATCH 034/280] 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; } } From 22761bb6ad4b121ae3b2319a9a2541a6bb8a982c Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 01:50:09 -0700 Subject: [PATCH 035/280] 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; From e289fe4dd7372a029ba85722e3ce99991e9d1d6b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 11:04:16 +0200 Subject: [PATCH 036/280] 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); } } From 9e8361976b6b0dc4c62ef48a4744ba1f59fe4346 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 02:41:43 -0700 Subject: [PATCH 037/280] 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); } } From fa1d85feca6beee9e07cf92f015a883a190c726a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 12:47:01 +0200 Subject: [PATCH 038/280] 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 */ From a37d5410b4486dd95692076e3da0368a4ed23577 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 12:50:54 +0200 Subject: [PATCH 039/280] APIDump: Added OnEntityAddEffect hook documentation. --- .../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 +} + + + + From 68c30790db17b9d21b2fcda4c7edec679162c577 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 10:59:59 -0700 Subject: [PATCH 040/280] 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; } } From e0a9f37d909e9d82ccac88dae910ce21a7fdba6f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 18 Jun 2014 12:13:01 +0200 Subject: [PATCH 041/280] (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); From f5529e544cf8350daf8a20bb8d997f85ee2824f7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 16 Jun 2014 20:22:17 -0700 Subject: [PATCH 042/280] 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; From 3e15c92d18c344c95bd805d7795db990258eed5a Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Fri, 20 Jun 2014 10:50:21 +0200 Subject: [PATCH 043/280] 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); } From a908f39dde1dc8866bda1a85b8443ae4cdaaa2b4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 21 Jun 2014 20:33:23 +0100 Subject: [PATCH 044/280] Rewrote furnace recipe parser * Fixes #110 --- src/FurnaceRecipe.cpp | 260 ++++++++++++++++++++++++++---------------- src/FurnaceRecipe.h | 22 ++++ 2 files changed, 185 insertions(+), 97 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()) + ASSERT(ParsingLine.empty()); + + while (std::getline(F, ParsingLine)) { - char c; - - ////////////////////////////////////////////////////////////////////////// - // comments - f >> c; - f.unget(); - if( c == '#' ) + 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; + int IItemID = 0, IItemCount = 0, IItemHealth = 0, IBurnTime = 0; + AString::size_type BeginPos = 1; // Begin at one after exclamation mark (bang) - // Optional health - f >> c; - if( c != ':' ) - f.unget(); - else + 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); } - - int CookTime; - f >> c; if( c != '@' ) { bSyntaxError = true; break; } - f >> CookTime; - - 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 - { - f >> OItemHealth; - } - - // 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) + F.close(); + + if (!SyntaxError.empty()) { - LOGERROR("ERROR: FurnaceRecipe, syntax error" ); + LOGWARN("Error parsing furnace recipes at %s", SyntaxError.c_str()); } - LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size()); + else + { + 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) +{ + 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) + { + SetParseError(a_ErrorString, a_Line, a_Begin, a_Delimiter); + return false; + } + } + + // 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"); + 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); + } + } + + 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; }; From 537467fe25386a67ef5cb9a33b9806ac2db0c894 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 21 Jun 2014 20:35:28 +0100 Subject: [PATCH 045/280] 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 :) From 4a01fba3aafef53ac8015bd5f6028fc677d6d245 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 00:06:58 +0100 Subject: [PATCH 046/280] 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); From 63ce2e8b37444f96d7892d555cb296947b3afbe5 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 22 Jun 2014 12:30:37 +0100 Subject: [PATCH 047/280] 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) From 33cc1f2a50d870b7d264ee5479068f8eee3aa458 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 20:44:01 +0100 Subject: [PATCH 048/280] 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 | 20 +++++++- src/Entities/ThrownSnowballEntity.cpp | 7 +-- src/Entities/ThrownSnowballEntity.h | 18 ++++++++ 8 files changed, 111 insertions(+), 62 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; } + 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); - 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); - } - - 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; + 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. + /** 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 From 4238b0ebe8d910186d4e160222f337b6e8b33cc8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 20:44:18 +0100 Subject: [PATCH 049/280] 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); From dad0037f987df594d6a1971af5b29f89c2d27901 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 20:44:55 +0100 Subject: [PATCH 050/280] 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; From c476fc3cf5a2bbdb27b61fcad290c84029721462 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 22 Jun 2014 21:49:37 +0100 Subject: [PATCH 051/280] 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; } From 7a236921319c44de38246ff73d5343e174dd560f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 23 Jun 2014 17:40:51 +0100 Subject: [PATCH 052/280] 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); } From e96a774f59305914af01bdd4b264e0fe37988463 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 24 Jun 2014 14:48:18 +0200 Subject: [PATCH 053/280] 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 cca0bcb251b4e9a603c4a0e2eb4e926dab6fa25d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6722 zcmeI1ZHyJw8OQ&yD+qK!i$ZBp?~1&v=!F$%v2QHuV$r35EaLkxckbM~8Zid{=gfJVwdu#E zNtxt#=XuWaKWEOIm*?EOyX~g?&^rD5+hweOIlMHpBYBz}$;e(>q3iu^D|>Fgmmo zUj=5e{B6wYn>SnLBw5NJNU`+Ex&|(FQBICv9hW!Z!B&v zq;>>2hqwRsRnNmab3Rn|MSO@C7dTf9YxmZ}rl0$&uQdimXU)r&;t{MJsYj(wzRL*9 zMO$Af9d5_Gw6c{3#iBIk!hsp2Baq=-auMUioNpg_ragvim&eaJN90NJ zI{B0=8sEcKT!U*dhHdyhwqpl&;yUcYICkTD z?7`H2~u=%2jartP#>;0<5-%*bry_y zezO_(@+?Z)qI9~y!K$W-tm|m@`Ee1Nc8q5fSv$JC{bWih9Iv8?l00O09F3T5d?occ{M=XwaMzN>0Qx-&wfJy&7Z=a?rn*4L^e+%J0U zyx8;-N6C@T)$3DbJgrE(VG>8`wH#+!yjQ-r5=hS~a%cUGd16J_73!#*wI@}M@2Kp; zlOpSCO*ad>?pRlSqbhn6S=cLLwIjO~U#qgPRlb-qYA#Lb#vANAA`?q_}3*xjVA8IXKJ52&# z4wM%dQ^&gcQC?t79m_&4F0&53pz14Cv*>hXpS7XN!#fJUd>Lcuh#pzbjIoNe%Yi9x zx{N)D<1~;{>2dQ~&njABvQKt`acw(Mz4=9TlL>5mB28sB6Jc#vqd{6E{<3&~9sBB`O#5yK!(DiDdJDD#&mWNv|@YuQnkGRJpR&RHQ< zj_;`As6COpV<5F(D0OR0d-@kn8`(kJnf4g#IvP8{vK{L> z8oOmgUySD}oB@>W>~ji~F7x-BWa_z&jdMrJRl}$S{T1@-nkT;cm8Od2sk6Vm zif0tnT%7Zeb#k*&IeV7vIG#~ByN?RTGYV&~<*9W{yer$4zk1k$;~9nBRuovr#4G6| zPhD4Q)bA0m`b$K*iLX|oh-pXFyVERiW2wlLUR7Rci688zuhS#&KRE*Z?3MVxf%rdA c`7emGDkbOB^SrH_$GtFVdY-bGSF)Vm=Y$7hZ~y=R 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 From dc284783f0698ad18601ba4ccba07646901b7de9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 24 Jun 2014 14:49:35 +0200 Subject: [PATCH 054/280] 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() From 5ab01c4d4205b61b41855eaeee534ae15b816331 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 15:27:19 +0200 Subject: [PATCH 055/280] 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" From 2dd7a0373be83ab917c3c115af519b42ce30e2a9 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 16:19:22 +0200 Subject: [PATCH 056/280] Better combining. --- src/Entities/Pickup.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 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()) { - m_Pickup->GetItem().AddCount(Item.m_ItemCount); - a_Entity->Destroy(); - m_FoundMatchingPickup = true; + 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) + { + a_Entity->Destroy(); + } + else + { + a_Entity->GetWorld()->BroadcastEntityMetadata(*a_Entity); + } + m_FoundMatchingPickup = true; } return false; } From dbcb7f819fc900164d644a1932d0cdc78b707ae0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 24 Jun 2014 17:50:38 +0200 Subject: [PATCH 057/280] 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; From e9aecfdf112601377ab6f640b77cb49c5a3a45bb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 25 Jun 2014 08:07:06 +0200 Subject: [PATCH 058/280] 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 From f96955496f4e53105b045fb7f3fa7d34ed82b147 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 26 Jun 2014 15:56:03 +0200 Subject: [PATCH 059/280] 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) From cba273dc7e381c00b214fa0806679170f4e4e2f3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 26 Jun 2014 17:20:48 +0200 Subject: [PATCH 060/280] 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 From bf3229867bc6a7d531fcb43c6519a951b043a732 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 26 Jun 2014 17:26:47 +0200 Subject: [PATCH 061/280] 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); From b90b0a1dffff366df639f49445afb43ae1a8a73c Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 17:51:19 +0200 Subject: [PATCH 062/280] FurnaceRecipe parser: Added an else branch, changed to a switch. --- src/FurnaceRecipe.cpp | 116 +++++++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 46 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 '!': { - return; + // 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; } - // 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); - } - } + 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 + ) + { + 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; + } + + 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()); } From 67e3c645d3a648ebd4d797019a993ed9c27cdb5e Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 17:52:37 +0200 Subject: [PATCH 063/280] 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 From 55bbdfa5d44a4bf7e66aa256ceba9ded3d2682dd Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 18:18:41 +0200 Subject: [PATCH 064/280] 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); From ec1015112c969798bae3efe87998c17d130b271a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 18:20:12 +0200 Subject: [PATCH 065/280] 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; From 0df644c9f7775862c6c359b238e3440536092e04 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Jun 2014 18:28:10 +0200 Subject: [PATCH 066/280] 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; From b832a202ab052b0544ca26225c4fe771cf31ede7 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 26 Jun 2014 18:30:02 +0100 Subject: [PATCH 067/280] 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()); } From 25a0264cc46d97f52bd836280fa5d2908846ac02 Mon Sep 17 00:00:00 2001 From: worktycho Date: Thu, 26 Jun 2014 19:04:56 +0100 Subject: [PATCH 068/280] 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) { From f68dc6210fe9b5f84c1f9fb3e57fc6285d71856c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 27 Jun 2014 09:24:11 +0200 Subject: [PATCH 069/280] 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") From 78442edf1d1c10e473741497d17342e7e330a964 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 27 Jun 2014 11:02:28 +0200 Subject: [PATCH 070/280] 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() From 62669f64dec3f615518af56a864a72d5c18280b8 Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 27 Jun 2014 10:27:02 +0100 Subject: [PATCH 071/280] 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) From 9e1829e4e6de6cf3c6686a8add8317706968bd46 Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 27 Jun 2014 10:45:43 +0100 Subject: [PATCH 072/280] 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) From 833d3284356972b06c6f34d7b91d1360a9570c5e Mon Sep 17 00:00:00 2001 From: worktycho Date: Fri, 27 Jun 2014 11:07:03 +0100 Subject: [PATCH 073/280] 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): From 9c29afb300200b661e35e3de3b6f26900f43517c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 27 Jun 2014 12:15:24 +0200 Subject: [PATCH 074/280] 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) From 563f706422554d1d8ff1121b9613ab9d34951a3b Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 19:34:53 +0200 Subject: [PATCH 075/280] 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] + ); } From d7bc5c5bd32f8b5560403ecf6631040891fe9b9e Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 20:23:05 +0200 Subject: [PATCH 076/280] 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) From 9926abd4f55d668dec9e06c2ba23fa3bb9209eeb Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 20:56:29 +0200 Subject: [PATCH 077/280] 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); From b6df30831d6b9b84bbb231dd8cfe4c1532666da4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 27 Jun 2014 23:13:26 +0100 Subject: [PATCH 078/280] 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) From 69befa9851e8957d9efa996b08217287a87dee8c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 27 Jun 2014 23:16:37 +0100 Subject: [PATCH 079/280] 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); + 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; } } @@ -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; } } From 0a20e19a64f88e66af68018cc46bc37dfdca7948 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 00:29:19 +0100 Subject: [PATCH 080/280] 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); } From de543ff73fa8bb846030ffc702ed4db9f2e89f7b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 00:29:32 +0100 Subject: [PATCH 081/280] 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) ) From 3e104c25e930eddedeb456c6cad456d7d01a38de Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Jun 2014 12:49:08 +0200 Subject: [PATCH 082/280] 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) From bef84b4821724c7119a3cb007d9e1265a56a27f0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 28 Jun 2014 12:59:09 +0200 Subject: [PATCH 083/280] 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); From 11d02a447e45e96e4652f25afc6d040597ad2064 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 28 Jun 2014 13:19:32 +0200 Subject: [PATCH 084/280] 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()); } From 48639ee4d25268525d94b2da32924164ff055d82 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Jun 2014 18:16:26 +0200 Subject: [PATCH 085/280] 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 From 1495bba17c04a5c756ba3a8eb3e881ef59aa1adf Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 28 Jun 2014 18:20:46 +0200 Subject: [PATCH 086/280] 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" From 61cb08b54698e9b70f629858a6a9c5b389db8b3e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 20:44:34 +0100 Subject: [PATCH 087/280] 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 +++++ .../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: From 5e66d9aeabcb759319c1045680443e72f0c1d75b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 20:45:05 +0100 Subject: [PATCH 088/280] 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; } From 085cb4256ed9dd343ab4049b6f1e3d4ef53855e8 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 28 Jun 2014 21:55:21 +0200 Subject: [PATCH 089/280] 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 From 35dc056f0350c5fda178d0c28230f0a6b0feabbc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 21:10:59 +0100 Subject: [PATCH 090/280] 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); From 536cb62f1c4ee47bf39a04240f9460953f3f8869 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 21:14:10 +0100 Subject: [PATCH 091/280] 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); } From 20b32fc44e69ef317dea7536eb8e31bc3fe6c562 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 29 Jun 2014 01:01:10 +0200 Subject: [PATCH 092/280] 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()); From 50e112788bc46460ec2c1972f811264c1a9b04cc Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 29 Jun 2014 01:40:15 +0200 Subject: [PATCH 093/280] 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); From dde641ce83de474187102f0efbbced826673f54d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 11:36:38 +0100 Subject: [PATCH 094/280] Properly implemented enderchests --- src/BlockEntities/EnderChestEntity.cpp | 97 ++++++++----------------- 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, 104 insertions(+), 101 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,60 +33,6 @@ cEnderChestEntity::~cEnderChestEntity() -bool cEnderChestEntity::LoadFromJson(const Json::Value & a_Value) -{ - 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) - { - cItem Item; - Item.FromJson(*itr); - SetSlot(SlotIdx, Item); - SlotIdx++; - } - 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--) - { - Json::Value Slot; - m_Contents.GetSlot(i).GetJson(Slot); - AllSlots.append(Slot); - } - a_Value["Slots"] = AllSlots; -} - - - - - -void cEnderChestEntity::SendTo(cClientHandle & a_Client) -{ - // 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); -} - - - - - void cEnderChestEntity::UsedBy(cPlayer * a_Player) { // If the window is not created, open it anew: @@ -106,21 +51,13 @@ void cEnderChestEntity::UsedBy(cPlayer * a_Player) a_Player->OpenWindow(Window); } } - - // 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::OpenNewWindow() { OpenWindow(new cEnderChestWindow(this)); } @@ -128,3 +65,33 @@ void cEnderChestEntity::OpenNewWindow(void) + +void cEnderChestEntity::LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid) +{ + int SlotIdx = 0; + for (Json::Value::iterator itr = a_Value.begin(); itr != a_Value.end(); ++itr) + { + cItem Item; + Item.FromJson(*itr); + a_Grid.SetSlot(SlotIdx, Item); + SlotIdx++; + } +} + + + + + +void cEnderChestEntity::SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid) +{ + 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); From 909e0ed95b508b0cc3779df342899e8661e6da96 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 11:41:50 +0100 Subject: [PATCH 095/280] 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)); } From 3c631fc0f95f383c53d18cd7760ab2e3a8609240 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 29 Jun 2014 18:27:41 +0200 Subject: [PATCH 096/280] 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] ); From 428cfb5c21ec5a35252b967eb306d6ba9b8e11b3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 22:41:31 +0100 Subject: [PATCH 097/280] 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 From b9d4431f6f2b60802d66da03f0b915bbd2c846cb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 22:44:01 +0100 Subject: [PATCH 098/280] 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; From 4ded58bfd1066d237588c542e511759e504c5c95 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 14:19:31 +0200 Subject: [PATCH 099/280] 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 { From aa753a92c092a4d35b2ff7d08259c3196abecf67 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 15:12:56 +0200 Subject: [PATCH 100/280] 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(); - } } From 5a152435b3fa1452a842519e21ab0643020bc1ab Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 15:22:48 +0200 Subject: [PATCH 101/280] 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 +}; From b94fef3089003b6b8958716cc8d12ffa03b5a779 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Jun 2014 19:15:10 +0100 Subject: [PATCH 102/280] 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); From 85fae0e521d3a2ea4f083ee2bc54ac7fbb357768 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Jun 2014 19:21:21 +0100 Subject: [PATCH 103/280] 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; From c3cde6232fae96a1c196d6bdf63b17ae996aee24 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 20:23:17 +0200 Subject: [PATCH 104/280] 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; From 6b8529544e7def8acb38ca80c01b4875ae313681 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 30 Jun 2014 21:00:06 +0200 Subject: [PATCH 105/280] 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) From a5a0533d793a64b76a84f23d4ca1754571ee0b40 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 30 Jun 2014 21:41:14 +0200 Subject: [PATCH 106/280] 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 From ac01a8e483f84d94f57c38d6882acd31d7e0fc91 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 30 Jun 2014 21:27:13 +0200 Subject: [PATCH 107/280] 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) From 8e11f7a1f64fd4d20495f1a4467ef168d18db92b Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 21:50:40 +0200 Subject: [PATCH 108/280] 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(); } From f9f3f7eac59c8de2bcb3f878849d355d5b9e3c9a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 30 Jun 2014 21:58:23 +0200 Subject: [PATCH 109/280] 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__)) From 84272fb155d48f999441b7aaba9ca8b21584ad21 Mon Sep 17 00:00:00 2001 From: worktycho Date: Mon, 30 Jun 2014 22:21:07 +0100 Subject: [PATCH 110/280] 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) From 0fb236bfe46782dc4e7c5b76db7b7c25671e3d66 Mon Sep 17 00:00:00 2001 From: worktycho Date: Mon, 30 Jun 2014 22:21:22 +0100 Subject: [PATCH 111/280] 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) From 4f60f5aef4517d6d3eaf2ea9f7aae30e6a97da25 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 06:40:38 +0200 Subject: [PATCH 112/280] 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) From 194678100a81134eeabb720d84fd987ef35946c6 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 06:41:35 +0200 Subject: [PATCH 113/280] 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 From eb8244f1c286ec33c30ba205eb5cebc1f2a0430d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 08:01:39 +0200 Subject: [PATCH 114/280] 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() From 64f6ddf1e2171dd7713f454c792916257e770f98 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 14:47:49 +0200 Subject: [PATCH 115/280] 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()); From decdbab2e68427914f3d284acc0f6184719306c0 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 15:23:29 +0200 Subject: [PATCH 116/280] 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) From 5a888f0a51ffbab6a6bd8ef24ff53ddf40a66ceb Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:30:13 +0200 Subject: [PATCH 117/280] Change documentation --- .../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 }; + + + + From 64e66674355c84c091564197dcbdf26806e61659 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:34:50 +0200 Subject: [PATCH 118/280] 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) { From 68007ab3e5aba33fb3a8e34c0301401aef594737 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 1 Jul 2014 20:42:23 +0200 Subject: [PATCH 119/280] 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; } From 0dfaad4123bc50202f97fc0e5d9fc5d3a9c8670c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Jul 2014 15:46:31 +0200 Subject: [PATCH 120/280] 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; } From bb0e88fcf85846f5ff3cfb43d964657f14a1b6b7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Jul 2014 21:28:45 +0200 Subject: [PATCH 121/280] 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") + + + + From b6d5d50b31e4fd0d34f42deb3aa51ebc8ae6f7f3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Jul 2014 22:19:14 +0200 Subject: [PATCH 122/280] 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 . From 7177806d31a5c6df52a8439bee2f4d150fa0eb47 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 30 Jun 2014 22:37:26 +0200 Subject: [PATCH 123/280] 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); From 284c1c0514168e30338f2ad372b7e7f185dba0c4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 1 Jul 2014 22:39:37 +0100 Subject: [PATCH 124/280] 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 From 4a9002045b86406ffd4bb16f67d33ae4060e6bc7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 2 Jul 2014 14:46:00 +0200 Subject: [PATCH 125/280] 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); From 835d00428c2af43050fa248ab988c431ec1be152 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 2 Jul 2014 14:49:08 +0200 Subject: [PATCH 126/280] 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 From 1c16862ae522b2124e7fd3b1a2dce7807f33b503 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 2 Jul 2014 16:30:13 +0200 Subject: [PATCH 127/280] 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 From 19caba5125e457a9663102989ea717898e3c2827 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 18:46:00 +0100 Subject: [PATCH 128/280] 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); From c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 18:46:13 +0100 Subject: [PATCH 129/280] 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 From abb49d3f338de4078177d1b95e3ed8d195119b50 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 18:51:37 +0100 Subject: [PATCH 130/280] 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()) { From 89a26cc786f3673cf7b5a100300d8aa595735cc3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 21:07:34 +0100 Subject: [PATCH 131/280] 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; } From 6f0a538385ee3fce2fa3e3ffd11bf23dd8db278c Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 2 Jul 2014 21:19:09 -0700 Subject: [PATCH 132/280] 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) From 78dd02f0c7195d046bfd4c50f96c12d95ad92ae0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 3 Jul 2014 10:11:46 +0200 Subject: [PATCH 133/280] 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 From 2dbed03cbce873d8a6582bfdc5c4b826b6e7eade Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 3 Jul 2014 17:49:21 +0200 Subject: [PATCH 134/280] 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; } From 20afd5d70ee61e969f4015f851c1d8f04cd02215 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 3 Jul 2014 17:53:57 +0200 Subject: [PATCH 135/280] 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 } From 632e8680b181477ebf6713a593cc69d0193a425b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Jul 2014 11:50:50 +0200 Subject: [PATCH 136/280] 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) + 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)) { - 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)) - { - 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); From a0d2df93272a6108f8c568e1eed665a1da5cb7ed Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 10:55:09 +0100 Subject: [PATCH 137/280] 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; } ; From ec2f576de69f2a6e73abb1aeadb173c0b2e12131 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Jul 2014 22:25:18 +0100 Subject: [PATCH 138/280] 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? From f6350662414044896e7971dcc792c83d5eaddbce Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 12:50:40 +0100 Subject: [PATCH 139/280] 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: From aa81a3ff3e2d9c66e699e244cab0b624167a9127 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Jul 2014 14:29:19 +0200 Subject: [PATCH 140/280] 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." }, From 41747f05002821901afc05dd25eb9567eac56eb6 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Jul 2014 15:07:41 +0200 Subject: [PATCH 141/280] 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; } From 546aab7b4a3e1fd28e912a9cb6507f04dbf7bd17 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Jul 2014 15:36:29 +0200 Subject: [PATCH 142/280] 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." }, From c7a5347cd63f9e39e9732ee4720423824fb41175 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Jul 2014 15:54:39 +0200 Subject: [PATCH 143/280] 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, " ")); From f4e3c01a710a2cc5118807a65f8d27519a19ef37 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 16:49:24 +0100 Subject: [PATCH 144/280] 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(); } From 2ead2538b108c8bf6b6c43648310ad7cf7073adc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 16:52:52 +0100 Subject: [PATCH 145/280] 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) From 79e558be349c40ed40b5eefefd29f563a570e404 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 17:42:40 +0100 Subject: [PATCH 146/280] 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) ); } From 25e986220662247cfeefe4a496da959f409859e9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 17:49:44 +0100 Subject: [PATCH 147/280] 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) From f4e11d194e9e4a2e85a9f9688312ad08ade45b83 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 22:07:26 +0100 Subject: [PATCH 148/280] 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; From 7a78f23b4a03d36dc6db56a7e269f5c181c2a6fb Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 5 Jul 2014 14:00:04 +0200 Subject: [PATCH 149/280] 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) + switch (a_ClickAction) { - return; - } - - if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick)) - { - 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)) + switch (a_ClickAction) { - ShiftClicked(a_Player, a_SlotNum, a_ClickedItem); - return; - } - - // Armors haven't a dbl click - if (a_ClickAction == caDblClick) - { - 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); From 460d6bd0cbb799a6e68f1bc264f55c3d89eb8206 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 5 Jul 2014 22:59:22 +0100 Subject: [PATCH 150/280] 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); From 9d7a59012c428e0207583f35c79938bcdab625b5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 6 Jul 2014 00:40:59 +0200 Subject: [PATCH 151/280] 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: From 66fa0155345f33a3be5661495af2f20d964b62b6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 5 Jul 2014 13:36:56 +0200 Subject: [PATCH 152/280] 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"}, From 562d14e8ecd058b029a248ab42ff60e36f7e2e62 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 6 Jul 2014 14:42:28 +0200 Subject: [PATCH 153/280] 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; From c3bd588826cd6de53f98cf96f2d275fc15df6f4f Mon Sep 17 00:00:00 2001 From: tycho Date: Sun, 6 Jul 2014 16:27:50 +0100 Subject: [PATCH 154/280] 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) From 9e44b0aae164f2456a452714f869cc9670732d8e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 6 Jul 2014 23:50:22 +0100 Subject: [PATCH 155/280] 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 +- .../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!" ); From 756c45d07bbf7e700caab660adf31bfd9f08b7e5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Jul 2014 21:12:25 +0100 Subject: [PATCH 156/280] 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)) && From 7c7501abc5345ec4eddd030ab4649b05354002c3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Jul 2014 21:14:15 +0100 Subject: [PATCH 157/280] 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)) { From 164ffe50adbadd4bc123f11d585fef5c447d776e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 8 Jul 2014 12:34:39 +0100 Subject: [PATCH 158/280] 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; From f2419afac5e138d64cbe968aad5a0838809f997c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 8 Jul 2014 23:11:06 +0200 Subject: [PATCH 159/280] 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" From 3615bf825b53d3e192ad7fe6d047bd713bc00394 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 9 Jul 2014 14:30:06 +0200 Subject: [PATCH 160/280] 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); From 0d88e71d182e68af8e8c40b7993b0e08f78cf13a Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 9 Jul 2014 14:35:01 +0200 Subject: [PATCH 161/280] 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" From 98950af634cca62af08ddf8c07b77f46165578a8 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Wed, 9 Jul 2014 16:53:01 +0200 Subject: [PATCH 162/280] 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; } From 74b6b398e7e5a2384f398b7dceaf45716bc70b6f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Jul 2014 19:56:50 +0100 Subject: [PATCH 163/280] 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); From da1d946b2b6cbb5d3e66c78adc09a4c472e04078 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 9 Jul 2014 22:04:26 +0100 Subject: [PATCH 164/280] 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(); From a6d30a72544a626680eec6facf5b7a67ebb8fda5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:20:55 +0200 Subject: [PATCH 165/280] 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 From ce670accc9740ad5f096658be9b0a39b4aabf0cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:37:21 +0200 Subject: [PATCH 166/280] 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; From db759891578c1cf4ce7f6d577b73fd1981ed502e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:46:09 +0200 Subject: [PATCH 167/280] 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; } From a11ad977ce9465c6c37050f7b9a82f1884645a34 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:10:42 +0200 Subject: [PATCH 168/280] 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; + } }; From 47ceb9e79db2a30dd5b5e48dd28f9c6f14ed2fc3 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:36:28 +0200 Subject: [PATCH 169/280] 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) From 944c04a209492826365b3785ccf1ed1fc70e122c Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 16:38:19 +0200 Subject: [PATCH 170/280] 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) From a8efb620881cd744cfd3cc74316a39bfec80b897 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 10 Jul 2014 17:46:07 +0200 Subject: [PATCH 171/280] 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; } }; From 9e22f46b15d4c92bfbfdd5fb23d7530348f1d534 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 18:18:32 +0200 Subject: [PATCH 172/280] 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: From 3b7e0969b98ecbd1d499a9ac2edd22a619ae5591 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 18:19:05 +0200 Subject: [PATCH 173/280] 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 + + + + From d790a45c5025e33712d8dd21f9349716ae4ee7d1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 18:28:20 +0200 Subject: [PATCH 174/280] 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." }, From 729cc7f6ffd34724e6c9d5e3a4367ba6b2c48241 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 23:04:33 +0200 Subject: [PATCH 175/280] Fixed style consistency. --- src/Chunk.cpp | 119 ++++++++++++++++++++++++++------------------------ src/Chunk.h | 4 +- 2 files changed, 63 insertions(+), 60 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); + int CenterX, CenterY, CenterZ; + GetRandomBlockCoords(CenterX, CenterY, CenterZ); - BLOCKTYPE PackCenterBlock = GetBlock(Center_X, Center_Y, Center_Z); - if (a_MobSpawner.CheckPackCenter(PackCenterBlock)) + BLOCKTYPE PackCenterBlock = GetBlock(CenterX, CenterY, CenterZ); + 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; - */ - - 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++; - } + 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); From 2bd486660ab4140c42da8f0f92304d64afc604e2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 00:06:05 +0200 Subject: [PATCH 176/280] 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; } From 6cea81e3833bafbf2916ab2a06edf31c0f9a536e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 00:06:58 +0200 Subject: [PATCH 177/280] 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; } From df65e8b7bb884fa67307073c0ef7010e3a8792b7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Jul 2014 12:06:16 +0100 Subject: [PATCH 178/280] Improved LinkedPowering speed * Additionally fixed wires powering other wires through blocks --- .../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; From ebea2b7efc1775de66e0c6b6ee66da6f9ad04422 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 13:13:10 +0200 Subject: [PATCH 179/280] 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); From 6a33fa84ae03ada5ddeb5861094a4030e612f827 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Jul 2014 12:43:24 +0100 Subject: [PATCH 180/280] 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; From ca6bcacdb9216237a25c05b2887ea69c6066356b Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 11 Jul 2014 17:58:35 +0200 Subject: [PATCH 181/280] 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; } From 416c160fb52b400e81e029a358c503053a2b93ec Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 11 Jul 2014 19:40:33 +0100 Subject: [PATCH 182/280] 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))) From f73042fb02ead13aa870f061a08f56d84ed1dc99 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Jul 2014 23:12:57 +0200 Subject: [PATCH 183/280] 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; From 4e6395d6ff9f34edb4dd36dc1f8e845c56b499f4 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 11 Jul 2014 17:27:29 -0700 Subject: [PATCH 184/280] 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); } } From 8cbd43e0434323dcb1ccba6e1b95a3ca16d35d44 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 11 Jul 2014 18:58:11 -0700 Subject: [PATCH 185/280] 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); From 68668d7a6eb3a989fc331f68fb660fff19b2f069 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 12 Jul 2014 12:44:59 +0200 Subject: [PATCH 186/280] 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 From e71e432633a26d0ab24d2da7e3707e4ab7060296 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:06:25 +0100 Subject: [PATCH 187/280] 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 +- .../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: { From 9ab0f259c763d72f6af2560007d4f5cd7b5694cd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:25:59 +0200 Subject: [PATCH 188/280] 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; } From c4f1284d9cca12f77184b7a0b9521e87f6533974 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:30:34 +0200 Subject: [PATCH 189/280] 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 From d72a81cb8e135695b947bea4bac320e21c9af278 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:34:32 +0200 Subject: [PATCH 190/280] 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; } From e2e0f52ecb8683a385066c2cc11d8544d8f93c60 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Jul 2014 23:48:39 +0200 Subject: [PATCH 191/280] 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: { From 9f4348fb09ae77aebcf0cdcfc2139613756dbcdc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:50:28 +0100 Subject: [PATCH 192/280] 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); + 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) + // 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; } }; From 945dfe75d753271394ef4109b66b1a526e5b2c93 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Jul 2014 22:52:45 +0100 Subject: [PATCH 193/280] 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 From 905fed09a64667f6f9cebf353dc65e6f094fbc72 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 00:51:42 +0200 Subject: [PATCH 194/280] 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); From dc5c43c0aa3ffb8ddaa0871ccf76d872d2393cdb Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 01:04:43 +0200 Subject: [PATCH 195/280] 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; } From e11f41d04821c9c00796066b45c4ace86415beb3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Jul 2014 00:12:32 +0100 Subject: [PATCH 196/280] 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 From 6484e9814a3a540518606f552398e0b82f91ab4d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Jul 2014 00:16:49 +0100 Subject: [PATCH 197/280] 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; From f1491ad1d1df3e0b4d22af8329c95106e794ba01 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 01:18:41 +0200 Subject: [PATCH 198/280] 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 From d529971e279609ae928d9077404b95bd595b5e52 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 02:08:02 +0200 Subject: [PATCH 199/280] 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 ++-- .../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); From 9b0b57bcbc9239f65ebfacf9df904d2bb77d2355 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 11:11:40 +0200 Subject: [PATCH 200/280] 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)) { From 31415aec63f03aeb92ec17ad3a3acb27aa6b2fc2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 13 Jul 2014 13:31:09 +0200 Subject: [PATCH 201/280] 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)); } From bfc485bfe2093dde665bc17588ea53218f964312 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:05:54 +0100 Subject: [PATCH 202/280] 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; From 4a6d606f7499582e6ec2953e663e98153a19a613 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 14:09:08 +0100 Subject: [PATCH 203/280] 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)); } From 2a0c041ad8eaa42e4293762df18d14c77e11ea49 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 13 Jul 2014 15:25:52 +0100 Subject: [PATCH 204/280] 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; } From 64697f0cabeeadf1d50717892f0815d8309f8b8a Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:29:43 +0100 Subject: [PATCH 205/280] 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; From 132b367316b2723ef573476a9fb78bcba6f09294 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:32:44 +0100 Subject: [PATCH 206/280] 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; From e1a561286a47ab52f4402ae9d08f143d26c60402 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 15:01:49 +0100 Subject: [PATCH 207/280] 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; } From 4315deb90b62a40a07bf4f3427b52a613738c102 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 13 Jul 2014 16:07:35 +0100 Subject: [PATCH 208/280] 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()); } From 8bb0baa842727bd2b8cb22775b18f7a5c3dad57e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 13 Jul 2014 17:07:30 +0200 Subject: [PATCH 209/280] 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, } From f77723128c6582e9c184706c7140c8bcf9c390c4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 15:23:23 -0700 Subject: [PATCH 210/280] 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 { From 0409daf7360d503e9e2b6258fa2582d7bdd7e5a0 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 15:43:49 -0700 Subject: [PATCH 211/280] 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 */ From 554e1c0dd3cedbcb4035d8ffa7351d56bee5dfb5 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 16:10:01 -0700 Subject: [PATCH 212/280] 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 = [[ From 1c6c612f76d25909dd190e08dc9f32d3ab2c507a Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 14 Jul 2014 19:07:31 +0200 Subject: [PATCH 213/280] 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; From 4e24f711abd3d6a93f01ee7c297eb67c8aedbd37 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 19:49:31 +0100 Subject: [PATCH 214/280] 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); } From 1929d16724de6f451c9485076b4091cbc457916c Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:26:36 +0100 Subject: [PATCH 215/280] 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)); + } +}; From 515c3cbc67816fb770ff7e32bd593bd55c26788c Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:28:16 +0100 Subject: [PATCH 216/280] 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) { } From 093b5c6456fd2c635441630c87853a3a00008af8 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:33:30 +0100 Subject: [PATCH 217/280] 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)); } }; From 333f4f982cbd24ffcb376594eddef439b3f05e9e Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 20:50:56 +0100 Subject: [PATCH 218/280] 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)); - } } ; From 2cd3443fbbb498f06227ed44db0c6a749cafdb76 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 21:21:17 +0100 Subject: [PATCH 219/280] 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 { From 061010288a99fd11f91bf713ac68068c57f79be7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 14 Jul 2014 13:46:15 -0700 Subject: [PATCH 220/280] 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; From 40bb98510a820469184e4947db3de22088b55fc7 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 13 Jul 2014 16:54:42 -0700 Subject: [PATCH 221/280] 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; } From f0187cc8f9922093b1e83687f869b813a8e90930 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 21:55:46 +0100 Subject: [PATCH 222/280] 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! } From ad6494fb36b1bb19f39796ad9d5ce4544a21f361 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 21:56:40 +0100 Subject: [PATCH 223/280] 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(); From 5b1552435f95887ba59c707e3635dcaf9cb358f4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 21:57:44 +0100 Subject: [PATCH 224/280] 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 } } } From 82fe5c05f0456a11fcb2079eaf44ee0565b0c3c7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 23:03:30 +0100 Subject: [PATCH 225/280] Fixed redstone simulator crash * Fixes #1176 * Fixed #1186 --- .../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) */ From 8fd636aa7235698263e3b85388a4f6373cbedb76 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 14 Jul 2014 23:59:24 +0100 Subject: [PATCH 226/280] 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)); + } } ; From 0e5fa2662aa2b559335a25ee78cd086f795be79e Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 15 Jul 2014 00:01:16 +0100 Subject: [PATCH 227/280] 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)); - } }; From 7195c7dfe2d0cc927c2a065662eba9be99817f70 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 08:28:10 +0200 Subject: [PATCH 228/280] 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), From e2a1118f88a32bd2912fc8abc81db0dacbb42531 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 08:48:12 +0200 Subject: [PATCH 229/280] 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 From d27485157847325c82fb93448f4ad05407abbd58 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 09:43:45 +0200 Subject: [PATCH 230/280] 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; } From 5193335efa1c0da08713715844801ee589dcfdf5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 09:48:11 +0200 Subject: [PATCH 231/280] 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 } } + + + + From f5259d765147cecb44a40ce5308387aba60cef8f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 11:24:48 +0200 Subject: [PATCH 232/280] 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 + From 01a31a1872bb7c33d5a4d0a13dae083c4ef7792e Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 15 Jul 2014 12:27:36 +0100 Subject: [PATCH 233/280] 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) { } From 2d245264b1b630dd9c6af6ffb6e6387e011a3198 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 13:34:45 +0200 Subject: [PATCH 234/280] 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: From 57f4e871bb820beaf56ee48e762a1ee276aa8afe Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 15 Jul 2014 12:52:02 +0100 Subject: [PATCH 235/280] 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 { From 7f4029f8f4b9b0c0b711c631ce704a3bbcb6e990 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 14:06:03 +0200 Subject: [PATCH 236/280] 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; From 9a970479efaef781ea8f69e3d8b8a1e2aa367847 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 14:54:24 +0200 Subject: [PATCH 237/280] 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 { From 74b6bf01a9932b12cb4ce6588086bfb00bf305a0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 15 Jul 2014 18:33:28 +0200 Subject: [PATCH 238/280] 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; } From d272e468212b2956f419fd1b595329f994151944 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 20:32:49 +0200 Subject: [PATCH 239/280] 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: From b5794517315f3e08d847332111537068e2b8af53 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Tue, 15 Jul 2014 20:34:49 +0200 Subject: [PATCH 240/280] 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; From cc452f51c8c4e1c886932d2f7965c7b3e4ab42fe Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Jul 2014 22:41:42 +0200 Subject: [PATCH 241/280] 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 | 44 ++++------ src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 2 +- 5 files changed, 103 insertions(+), 71 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); + 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() { return m_EntityEffectType; } - cEntityEffect GetEntityEffect() { return m_EntityEffect; } - int GetPotionName() { return m_PotionName; } + 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()); From 1df5a1f237cd4b620ada8aa9706d052ec54f1519 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 15 Jul 2014 22:53:44 +0100 Subject: [PATCH 242/280] 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; From 1f6854792cdd6792b27c4f9f3d7d857df9dd64bf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 00:03:47 +0100 Subject: [PATCH 243/280] 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 From f2c4f56ccd1862fb6d02f6f2dfb3230123f465cf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 11:21:02 +0100 Subject: [PATCH 244/280] 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); }; From ad247735fdd28f9dec6c8e86507bc7e75e50e448 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 11:23:26 +0100 Subject: [PATCH 245/280] 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 From 2189f37c20198a5889d5477aa4abcc116437861d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 11:38:52 +0100 Subject: [PATCH 246/280] 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 {} } ; From c5d00f3ec5acec908cd54b194a0042e0681764a5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 12:05:09 +0100 Subject: [PATCH 247/280] 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()); From 9194438fb552dc2f112535e2420d94de7af40e17 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 22:21:00 +0100 Subject: [PATCH 248/280] 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();) From 960fcaa90c3ba4d57ff2205259471799e0418d12 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 22:22:00 +0100 Subject: [PATCH 249/280] 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) { From 174906efca7f81655a57fa0a30c1158a16e77117 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 22:22:45 +0100 Subject: [PATCH 250/280] 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; From cd1e6f8ef028ea2a24e52190d305a62e6cfa62ab Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 10:24:29 +0200 Subject: [PATCH 251/280] 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 From 64c8b0d51b0ee8323dded6d22ac3b4754daa15d2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 10:51:44 +0200 Subject: [PATCH 252/280] Reformatted cItemPotionHandler. --- src/BlockID.h | 3 +- src/Items/ItemPotion.h | 130 +++++++++++++++++++++++++---------------- 2 files changed, 82 insertions(+), 51 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) { - // First six bits (least significant) - return a_ItemDamage & 0x3F; } - cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) + + /** 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 four bits (least significant) + // Lowest six bits + return (a_ItemDamage & 0x3f); + } + + + /** Translates the potion's damage value into the entity effect that the potion gives */ + static cEntityEffect::eType GetEntityEffectType(short a_ItemDamage) + { + // 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) { - } - - 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 + // 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 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; } }; + + + + From 430d8b42a5b8889ff3c0bfaea84ede7e543e2b64 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 11:07:10 +0200 Subject: [PATCH 253/280] 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 From 70f304a96b48de5c31993d9ee87c4b661e3c615c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 11:07:33 +0200 Subject: [PATCH 254/280] 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); } From db36f1a9fad7a79d489c36abd6140e7b48f7d413 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 13:54:28 +0100 Subject: [PATCH 255/280] 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; } From 3dd9649665e88e27298d93fd3c08b76ac5b0befa Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 14:32:52 +0100 Subject: [PATCH 256/280] 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); From 993fd14ddfc881cf5be951df77da0338124d68cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 16:33:09 +0200 Subject: [PATCH 257/280] 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) From 7fff12bfacbb4bef1c02cea0ec10fdc9a6fb64e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 19:13:23 +0200 Subject: [PATCH 258/280] 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 #include #include "BlockID.h" -#include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it +#include "Mobs/Monster.h" // This is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index 35bf57380..a89fa72df 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -61,7 +61,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist { if ((a_DistanceMin == 1) || (itr->first > a_DistanceMin)) { - toReturn.m_Begin = itr; // this is the first one with distance > a_DistanceMin; + toReturn.m_Begin = itr; // This is the first one with distance > a_DistanceMin; } } @@ -69,7 +69,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist { if ((a_DistanceMax != 1) && (itr->first > a_DistanceMax)) { - toReturn.m_End = itr; // this is just after the last one with distance < a_DistanceMax + toReturn.m_End = itr; // This is just after the last one with distance < a_DistanceMax // Note : if we are not going through this, it's ok, toReturn.m_End will be end(); break; } diff --git a/src/MobSpawner.h b/src/MobSpawner.h index aa2935916..f3c56fe2d 100644 --- a/src/MobSpawner.h +++ b/src/MobSpawner.h @@ -6,7 +6,7 @@ #include "ChunkDef.h" #include "Chunk.h" #include "FastRandom.h" -#include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it +#include "Mobs/Monster.h" // This is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it diff --git a/src/Root.cpp b/src/Root.cpp index 235a1b108..6347adcf0 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -105,7 +105,7 @@ void cRoot::Start(void) #ifdef _WIN32 HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu(hwnd, FALSE); - EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling + EnableMenuItem(hmenu, SC_CLOSE, MF_GRAYED); // Disable close button when starting up; it causes problems with our CTRL-CLOSE handling #endif cDeadlockDetect dd; @@ -202,7 +202,7 @@ void cRoot::Start(void) LOG("Startup complete, took %lld ms!", finishmseconds); #ifdef _WIN32 - EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button + EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button #endif while (!m_bStop && !m_bRestart && !g_TERMINATE_EVENT_RAISED) // These are modified by external threads @@ -607,7 +607,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac m_BestRating = Rating; ++m_NumMatches; } - if (Rating == m_NameLength) // Perfect match + if (Rating == m_NameLength) // Perfect match { return true; } diff --git a/src/Scoreboard.h b/src/Scoreboard.h index 5f91535f8..f53b8c803 100644 --- a/src/Scoreboard.h +++ b/src/Scoreboard.h @@ -118,7 +118,7 @@ private: friend class cScoreboardSerializer; -}; // tolua_export +}; // tolua_export @@ -197,7 +197,7 @@ private: friend class cScoreboardSerializer; -}; // tolua_export +}; // tolua_export @@ -301,7 +301,7 @@ private: friend class cScoreboardSerializer; -}; // tolua_export +}; // tolua_export diff --git a/src/Server.cpp b/src/Server.cpp index 17551eeb1..81ecd38b2 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -202,7 +202,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_PlayerCount = 0; m_PlayerCountDiff = 0; - m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind + m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind if (m_bIsConnected) { @@ -213,7 +213,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) LOGINFO("Compatible clients: %s", MCS_CLIENT_VERSIONS); LOGINFO("Compatible protocol versions %s", MCS_PROTOCOL_VERSIONS); - if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever + if (cSocket::WSAStartup() != 0) // Only does anything on Windows, but whatever { LOGERROR("WSAStartup() != 0"); return false; @@ -409,7 +409,7 @@ void cServer::TickClients(float a_Dt) for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr) { delete *itr; - } // for itr - RemoveClients[] + } // for itr - RemoveClients[] } diff --git a/src/Server.h b/src/Server.h index a6b7297e8..b03359f03 100644 --- a/src/Server.h +++ b/src/Server.h @@ -133,7 +133,7 @@ public: // tolua_export private: - friend class cRoot; // so cRoot can create and destroy cServer + friend class cRoot; // so cRoot can create and destroy cServer /** When NotifyClientWrite() is called, it is queued for this thread to process (to avoid deadlocks between cSocketThreads, cClientHandle and cChunkMap) */ class cNotifyWriteThread : @@ -194,7 +194,7 @@ private: int m_ClientViewDistance; // The default view distance for clients; settable in Settings.ini - bool m_bIsConnected; // true - connected false - not connected + bool m_bIsConnected; // true - connected false - not connected bool m_bRestarting; @@ -244,7 +244,7 @@ private: // cListenThread::cCallback overrides: virtual void OnConnectionAccepted(cSocket & a_Socket) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Statistics.h b/src/Statistics.h index 49750e8c0..d70a2aeab 100644 --- a/src/Statistics.h +++ b/src/Statistics.h @@ -118,7 +118,7 @@ private: /* Signed (?) integral value. */ -typedef int StatValue; // tolua_export +typedef int StatValue; // tolua_export @@ -157,7 +157,7 @@ private: // TODO 10-05-2014 xdot: Use, mine, craft statistics -}; // tolua_export +}; // tolua_export diff --git a/src/Tracer.cpp b/src/Tracer.cpp index be42430a5..d788d9e26 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -7,7 +7,7 @@ #include "Entities/Entity.h" #ifndef _WIN32 - #include // abs() + #include #endif @@ -247,7 +247,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int // return 1 = hit, other is not hit int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,float y3) { - //float linx, liny; + // float linx, liny; float d=(x1-x0)*(y3-y2)-(y1-y0)*(x3-x2); if (abs(d)<0.001) {return 0;} @@ -257,8 +257,8 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl float CD=((y0-y2)*(x1-x0)-(x0-x2)*(y1-y0))/d; if (CD>=0.0 && CD<=1.0) { - //linx=x0+AB*(x1-x0); - //liny=y0+AB*(y1-y0); + // linx=x0+AB*(x1-x0); + // liny=y0+AB*(y1-y0); return 1; } } @@ -291,7 +291,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f if (sI < 0 || sI > 1) return 0; // no intersection - //Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } @@ -310,8 +310,8 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve Vector3f Look = (end - start); Look.Normalize(); - float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1 - if(dot < 0) + float dot = Look.Dot( Vector3f(-1, 0, 0) ); // first face normal is x -1 + if (dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x, BlockPos.y, BlockPos.x, BlockPos.y + 1 ); if(Lines == 1) @@ -324,7 +324,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 + dot = Look.Dot( Vector3f(0, 0, -1) ); // second face normal is z -1 if(dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z, BlockPos.y, BlockPos.z, BlockPos.y + 1 ); @@ -338,7 +338,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 + dot = Look.Dot( Vector3f(1, 0, 0) ); // third face normal is x 1 if(dot < 0) { int Lines = LinesCross( start.x, start.y, end.x, end.y, BlockPos.x + 1, BlockPos.y, BlockPos.x + 1, BlockPos.y + 1 ); @@ -352,7 +352,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 + dot = Look.Dot( Vector3f(0, 0, 1) ); // fourth face normal is z 1 if(dot < 0) { int Lines = LinesCross( start.z, start.y, end.z, end.y, BlockPos.z + 1, BlockPos.y, BlockPos.z + 1, BlockPos.y + 1 ); @@ -366,7 +366,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 + dot = Look.Dot( Vector3f(0, 1, 0) ); // fifth face normal is y 1 if(dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y + 1, BlockPos.x, BlockPos.y + 1, BlockPos.x + 1 ); @@ -380,7 +380,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve } } } - dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 + dot = Look.Dot( Vector3f(0, -1, 0) ); // sixth face normal is y -1 if(dot < 0) { int Lines = LinesCross( start.y, start.x, end.y, end.x, BlockPos.y, BlockPos.x, BlockPos.y, BlockPos.x + 1 ); diff --git a/src/Vector3.h b/src/Vector3.h index c175bf135..1dcb38f64 100644 --- a/src/Vector3.h +++ b/src/Vector3.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 #include #include diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index d80849433..b3eab5659 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -391,7 +391,7 @@ AString cWebAdmin::GetDefaultPage(void) Content += "

Players:

    "; cPlayerAccum PlayerAccum; - cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players + cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players if( World != NULL ) { World->ForEachPlayer(PlayerAccum); diff --git a/src/WebAdmin.h b/src/WebAdmin.h index d5e45828f..d679a097c 100644 --- a/src/WebAdmin.h +++ b/src/WebAdmin.h @@ -60,11 +60,11 @@ struct HTTPRequest StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS << /** Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method) */ - StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << + StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << /** Same as PostParams */ FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS << -} ; // tolua_export +} ; // tolua_export @@ -120,7 +120,7 @@ public: void RemovePlugin(cWebPlugin * a_Plugin); // TODO: Convert this to the auto-locking callback mechanism used for looping players in worlds and such - PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << + PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << // tolua_begin @@ -218,7 +218,7 @@ protected: virtual void OnRequestBegun (cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override; virtual void OnRequestBody (cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) override; virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/World.cpp b/src/World.cpp index b3284942a..7f30f9b39 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -375,17 +375,15 @@ void cWorld::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ) void cWorld::InitializeSpawn(void) { - if (!m_IsSpawnExplicitlySet) // Check if spawn position was already explicitly set or not + if (!m_IsSpawnExplicitlySet) { - GenerateRandomSpawn(); // Generate random solid-land coordinate and then write it to the world configuration - + // Spawn position wasn't already explicitly set, enerate random solid-land coordinate and then write it to the world configuration: + GenerateRandomSpawn(); cIniFile IniFile; IniFile.ReadFile(m_IniFileName); - IniFile.SetValueF("SpawnPosition", "X", m_SpawnX); IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY); IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ); - IniFile.WriteFile(m_IniFileName); } @@ -648,7 +646,7 @@ void cWorld::GenerateRandomSpawn(void) while (IsBlockWaterOrIce(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ))) { - if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords + if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords { m_SpawnX += cChunkDef::Width; } @@ -658,7 +656,7 @@ void cWorld::GenerateRandomSpawn(void) } } - m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height + m_SpawnY = (double)GetHeight((int)m_SpawnX, (int)m_SpawnZ) + 1.6f; // 1.6f to accomodate player height LOGD("Generated random spawnpoint %i %i %i", (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ); } @@ -770,12 +768,12 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_ChunkMap->FastSetQueuedBlocks(); - if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes + if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes { SaveAllChunks(); } - if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds + if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds { UnloadUnusedChunks(); } @@ -861,8 +859,8 @@ void cWorld::TickMobs(float a_Dt) SpawnMobFinalize(*itr2); } } - } // for i - AllFamilies[] - } // if (Spawning enabled) + } // for i - AllFamilies[] + } // if (Spawning enabled) // move close mobs cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block) @@ -972,7 +970,7 @@ void cWorld::TickClients(float a_Dt) for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr) { delete *itr; - } // for itr - RemoveClients[] + } // for itr - RemoveClients[] } @@ -3026,18 +3024,18 @@ void cWorld::TabCompleteUserName(const AString & a_Text, AStringVector & a_Resul cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(), end = m_Players.end(); itr != end; ++itr) { - size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space + size_t LastSpace = a_Text.find_last_of(" "); // Find the position of the last space - AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word + AString LastWord = a_Text.substr(LastSpace + 1, a_Text.length()); // Find the last word AString PlayerName ((*itr)->GetName()); - size_t Found = PlayerName.find(LastWord); // Try to find last word in playername + size_t Found = PlayerName.find(LastWord); // Try to find last word in playername if (Found == AString::npos) { - continue; // No match + continue; // No match } - a_Results.push_back(PlayerName); // Match! + a_Results.push_back(PlayerName); // Match! } } diff --git a/src/World.h b/src/World.h index a3b152a80..725e1eb71 100644 --- a/src/World.h +++ b/src/World.h @@ -218,14 +218,14 @@ public: void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL); virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = NULL) override; - 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); // tolua_export + 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); // tolua_export void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL); void BroadcastRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude = NULL); 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, 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 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); void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); @@ -859,7 +859,7 @@ private: Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent. Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred - std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) + std::map m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed) NIBBLETYPE m_SkyDarkness; @@ -1011,7 +1011,7 @@ private: /** Adds the players queued in the m_PlayersToAdd queue into the m_Players list. Assumes it is called from the Tick thread. */ void AddQueuedPlayers(void); -}; // tolua_export +}; // tolua_export diff --git a/src/main.cpp b/src/main.cpp index c8ff31f07..f485d8f8f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,17 +3,17 @@ #include "Root.h" -#include //std::exception -#include //std::signal -#include //exit() +#include +#include +#include #ifdef _MSC_VER #include #endif // _MSC_VER // Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P -bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot -bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console +bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot +bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console @@ -76,7 +76,7 @@ void NonCtrlHandler(int a_Signal) case SIGINT: case SIGTERM: { - std::signal(a_Signal, SIG_IGN); // Server is shutting down, wait for it... + std::signal(a_Signal, SIG_IGN); // Server is shutting down, wait for it... break; } default: break; @@ -158,9 +158,9 @@ BOOL CtrlHandler(DWORD fdwCtrlType) g_TERMINATE_EVENT_RAISED = true; LOGD("Terminate event raised from the Windows CtrlHandler"); - if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... + if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore... { - while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly + while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly } return TRUE; @@ -233,7 +233,7 @@ int main( int argc, char **argv ) std::signal(SIGABRT, NonCtrlHandler); #ifdef SIGABRT_COMPAT std::signal(SIGABRT_COMPAT, NonCtrlHandler); - #endif // SIGABRT_COMPAT + #endif // SIGABRT_COMPAT #endif // DEBUG: test the dumpfile creation: From 68cc9c6f91bbbadedf3641099e0aa17352e4dde8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 17 Jul 2014 21:35:34 +0200 Subject: [PATCH 259/280] Fix sapling drop. --- src/Blocks/BlockSapling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h index 3d925029a..3f443b734 100644 --- a/src/Blocks/BlockSapling.h +++ b/src/Blocks/BlockSapling.h @@ -21,7 +21,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { // Only the first 2 bits contain the display information, the others are for growing - a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 3)); + a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x7)); } From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: [PATCH 260/280] Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/Bindings/DeprecatedBindings.cpp | 18 +-- src/Bindings/LuaChunkStay.cpp | 2 +- src/Bindings/LuaState.cpp | 4 +- src/Bindings/LuaState.h | 2 +- src/Bindings/LuaWindow.cpp | 4 +- src/Bindings/ManualBindings.cpp | 4 +- src/Bindings/PluginLua.cpp | 4 +- src/Bindings/PluginManager.h | 2 +- src/Bindings/WebPlugin.cpp | 2 +- src/Bindings/WebPlugin.h | 2 +- src/BlockArea.cpp | 4 +- src/BlockEntities/BlockEntityWithItems.h | 2 +- src/BlockEntities/CommandBlockEntity.cpp | 2 +- src/BlockEntities/DropSpenserEntity.cpp | 8 +- src/BlockEntities/HopperEntity.cpp | 8 +- src/BlockID.h | 4 +- src/Blocks/BlockBed.cpp | 8 +- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockComparator.h | 2 +- src/Blocks/BlockDropSpenser.h | 4 +- src/Blocks/BlockEnderchest.h | 2 +- src/Blocks/BlockFarmland.h | 2 +- src/Blocks/BlockFire.h | 32 ++--- src/Blocks/BlockLadder.h | 2 +- src/Blocks/BlockLeaves.h | 2 +- src/Blocks/BlockPiston.cpp | 4 +- src/Blocks/BlockPiston.h | 2 +- src/Blocks/BlockPortal.h | 4 +- src/Blocks/BlockQuartz.h | 10 +- src/Blocks/BlockRail.h | 2 +- src/Blocks/BlockRedstoneRepeater.h | 2 +- src/Blocks/BlockSideways.h | 10 +- src/Blocks/BlockSnow.h | 4 +- src/Blocks/BlockStairs.h | 2 +- src/Blocks/BlockTorch.h | 12 +- src/Blocks/MetaRotator.h | 2 +- src/ByteBuffer.cpp | 2 +- src/Chunk.cpp | 4 +- src/ChunkSender.cpp | 4 +- src/ClientHandle.cpp | 2 +- src/CommandOutput.cpp | 4 +- src/CompositeChat.cpp | 18 +-- src/CraftingRecipes.cpp | 6 +- src/Cuboid.cpp | 2 +- src/Entities/ArrowEntity.cpp | 12 +- src/Entities/ArrowEntity.h | 2 +- src/Entities/Boat.cpp | 2 +- src/Entities/Entity.cpp | 28 ++--- src/Entities/Entity.h | 2 +- src/Entities/EntityEffect.cpp | 16 +-- src/Entities/ExpBottleEntity.h | 2 +- src/Entities/FireChargeEntity.h | 2 +- src/Entities/FireworkEntity.h | 2 +- src/Entities/Floater.cpp | 18 +-- src/Entities/Floater.h | 4 +- src/Entities/GhastFireballEntity.h | 2 +- src/Entities/HangingEntity.cpp | 4 +- src/Entities/ItemFrame.cpp | 2 +- src/Entities/Minecart.cpp | 92 +++++++------- src/Entities/Painting.h | 4 +- src/Entities/Pickup.cpp | 12 +- src/Entities/Pickup.h | 4 +- src/Entities/Player.cpp | 42 +++---- src/Entities/Player.h | 6 +- src/Entities/ProjectileEntity.cpp | 6 +- src/Entities/ProjectileEntity.h | 2 +- src/Entities/SplashPotionEntity.cpp | 4 +- src/Entities/SplashPotionEntity.h | 2 +- src/Entities/TNTEntity.h | 2 +- src/Entities/ThrownEggEntity.h | 2 +- src/Entities/ThrownEnderPearlEntity.h | 2 +- src/Entities/ThrownSnowballEntity.h | 2 +- src/Entities/WitherSkullEntity.h | 2 +- src/Generating/BioGen.cpp | 18 +-- src/Generating/Caves.cpp | 10 +- src/Generating/ChunkGenerator.cpp | 4 +- src/Generating/CompoGen.cpp | 12 +- src/Generating/ComposableGenerator.cpp | 4 +- src/Generating/DistortedHeightmap.cpp | 10 +- src/Generating/EndGen.cpp | 2 +- src/Generating/FinishGen.cpp | 22 ++-- src/Generating/GridStructGen.cpp | 2 +- src/Generating/HeiGen.cpp | 14 +-- src/Generating/MineShafts.cpp | 14 +-- src/Generating/NetherFortGen.cpp | 6 +- src/Generating/Noise3DGenerator.cpp | 4 +- src/Generating/POCPieceGenerator.cpp | 2 +- src/Generating/PieceGenerator.cpp | 16 +-- .../Prefabs/AlchemistVillagePrefabs.cpp | 40 +++--- .../Prefabs/JapaneseVillagePrefabs.cpp | 38 +++--- src/Generating/Prefabs/NetherFortPrefabs.cpp | 68 +++++----- .../Prefabs/PlainsVillagePrefabs.cpp | 72 +++++------ src/Generating/Prefabs/RainbowRoadPrefabs.cpp | 24 ++-- .../Prefabs/SandFlatRoofVillagePrefabs.cpp | 24 ++-- src/Generating/Prefabs/SandVillagePrefabs.cpp | 32 ++--- src/Generating/Prefabs/TestRailsPrefabs.cpp | 10 +- .../Prefabs/UnderwaterBasePrefabs.cpp | 28 ++--- src/Generating/RainbowRoadsGen.cpp | 4 +- src/Generating/Ravines.cpp | 4 +- src/Generating/StructGen.cpp | 12 +- src/Generating/TestRailsGen.cpp | 4 +- src/Generating/Trees.cpp | 10 +- src/Generating/UnderwaterBaseGen.cpp | 4 +- src/Generating/VillageGen.cpp | 2 +- src/HTTPServer/HTTPMessage.cpp | 6 +- src/HTTPServer/HTTPServer.cpp | 2 +- src/HTTPServer/MultipartParser.cpp | 4 +- src/HTTPServer/NameValueParser.cpp | 2 +- src/Item.cpp | 2 +- src/Items/ItemBucket.h | 4 +- src/Items/ItemFishingRod.h | 27 ++-- src/Items/ItemHandler.cpp | 4 +- src/Items/ItemHandler.h | 8 +- src/Items/ItemItemFrame.h | 4 +- src/Items/ItemLeaves.h | 2 +- src/Items/ItemLilypad.h | 4 +- src/Items/ItemPainting.h | 8 +- src/Items/ItemRedstoneDust.h | 2 +- src/Items/ItemSeeds.h | 2 +- src/LightingThread.cpp | 4 +- src/MCLogger.cpp | 2 +- src/Mobs/Creeper.cpp | 2 +- src/Mobs/Monster.cpp | 24 ++-- src/Mobs/Monster.h | 14 +-- src/Mobs/Sheep.cpp | 4 +- src/Mobs/Villager.cpp | 4 +- src/Mobs/Villager.h | 5 +- src/Mobs/Wolf.cpp | 8 +- src/Noise.cpp | 14 +-- src/Noise.h | 4 +- src/OSSupport/CriticalSection.cpp | 6 +- src/OSSupport/File.cpp | 4 +- src/OSSupport/Semaphore.cpp | 8 +- src/OSSupport/Semaphore.h | 2 +- src/OSSupport/Sleep.cpp | 2 +- src/OSSupport/SocketThreads.cpp | 2 +- src/OSSupport/Thread.cpp | 12 +- src/PolarSSL++/Sha1Checksum.cpp | 2 +- src/Protocol/Protocol.h | 2 +- src/Protocol/Protocol125.cpp | 74 +++++------ src/Protocol/Protocol125.h | 4 +- src/Protocol/Protocol132.cpp | 4 +- src/Protocol/Protocol14x.cpp | 4 +- src/Protocol/Protocol15x.cpp | 2 +- src/Protocol/Protocol16x.cpp | 14 +-- src/Protocol/Protocol17x.cpp | 64 +++++----- src/Protocol/ProtocolRecognizer.h | 4 +- src/RCONServer.cpp | 6 +- src/Server.cpp | 6 +- src/Simulator/DelayedFluidSimulator.cpp | 6 +- src/Simulator/FireSimulator.cpp | 2 +- src/Simulator/FluidSimulator.cpp | 16 +-- .../IncrementalRedstoneSimulator.cpp | 118 +++++++++--------- src/Simulator/IncrementalRedstoneSimulator.h | 24 ++-- src/Simulator/NoopRedstoneSimulator.h | 2 +- src/StringUtils.cpp | 8 +- src/Tracer.cpp | 32 +++-- src/UI/SlotArea.cpp | 32 ++--- src/UI/Window.cpp | 18 +-- src/WebAdmin.cpp | 2 +- src/World.cpp | 20 +-- src/World.h | 2 +- src/WorldStorage/FastNBT.cpp | 4 +- src/WorldStorage/FireworksSerializer.cpp | 4 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/SchematicFileSerializer.cpp | 2 +- src/WorldStorage/ScoreboardSerializer.cpp | 10 +- src/WorldStorage/WSSAnvil.cpp | 8 +- src/WorldStorage/WSSCompact.cpp | 22 ++-- src/WorldStorage/WSSCompact.h | 6 +- src/WorldStorage/WorldStorage.cpp | 4 +- src/XMLParser.h | 2 +- src/main.cpp | 4 +- 173 files changed, 893 insertions(+), 867 deletions(-) diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d51ba2da3..d2e60945d 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -39,7 +39,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S) tolua_pushnumber(tolua_S,(lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -65,7 +65,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S) tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -91,7 +91,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -117,7 +117,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -143,7 +143,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -169,7 +169,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -195,7 +195,7 @@ static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) tolua_pushboolean(tolua_S, cBlockInfo::RequiresSpecialTool((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -221,7 +221,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE @@ -247,7 +247,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S) tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType)); return 1; } -#endif //#ifndef TOLUA_DISABLE +#endif // #ifndef TOLUA_DISABLE diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp index 985a18a95..59b02d8f7 100644 --- a/src/Bindings/LuaChunkStay.cpp +++ b/src/Bindings/LuaChunkStay.cpp @@ -76,7 +76,7 @@ bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos) -void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index) +void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index) { // Check that the element has 2 coords: int NumCoords = luaL_getn(L, -1); diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 32638df96..7d918cf2b 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -40,7 +40,7 @@ const cLuaState::cRet cLuaState::Return = {}; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLuaState: cLuaState::cLuaState(const AString & a_SubsystemName) : @@ -1371,7 +1371,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLuaState::cRef: cLuaState::cRef::cRef(void) : diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index b1ac3578a..afac77ce8 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -128,7 +128,7 @@ public: /** Creates a new instance. The LuaState is not initialized. - a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins, + a_SubsystemName is used for reporting problems in the console, it is "plugin %s" for plugins, or "LuaScript" for the cLuaScript template */ cLuaState(const AString & a_SubsystemName); diff --git a/src/Bindings/LuaWindow.cpp b/src/Bindings/LuaWindow.cpp index 733304eb2..1a2582ab0 100644 --- a/src/Bindings/LuaWindow.cpp +++ b/src/Bindings/LuaWindow.cpp @@ -7,13 +7,13 @@ #include "../UI/SlotArea.h" #include "PluginLua.h" #include "../Entities/Player.h" -#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL +#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLuaWindow: cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) : diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 88d40bfd9..bb059193b 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2065,7 +2065,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S) { lua_pushstring(tolua_S, it->first.c_str() ); tolua_pushusertype(tolua_S, &(it->second), "HTTPFormData" ); - //lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data + // lua_pushlstring(tolua_S, it->second.Value.c_str(), it->second.Value.size() ); // Might contain binary data lua_settable(tolua_S, top); } @@ -2114,7 +2114,7 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) { const AString & FancyName = iter->first; const AString & WebName = iter->second; - tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key + tolua_pushstring( tolua_S, WebName.c_str() ); // Because the WebName is supposed to be unique, use it as key tolua_pushstring( tolua_S, FancyName.c_str() ); // lua_rawset(tolua_S, -3); diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index c36763c38..f69435370 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -25,7 +25,7 @@ extern "C" -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPluginLua: cPluginLua::cPluginLua(const AString & a_PluginDirectory) : @@ -1670,7 +1670,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request ) sWebPluginTab * Tab = 0; for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr) { - if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr + if ((*itr)->SafeTitle.compare(SafeTabName) == 0) // This is the one! Rawr { Tab = *itr; break; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 94a366d33..bf181a55f 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -336,7 +336,7 @@ private: /** 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 +} ; // tolua_export diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index bf45405ba..bc1a9ac8c 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -71,7 +71,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest { for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { - if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr + if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr { Tab = *itr; break; diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h index 22587b892..3587ac637 100644 --- a/src/Bindings/WebPlugin.h +++ b/src/Bindings/WebPlugin.h @@ -36,7 +36,7 @@ public: TabList & GetTabs() { return m_Tabs; } typedef std::list< std::pair > TabNameList; - TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS << + TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS << std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request ); private: diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 1df60b099..a0dcb5ec8 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -269,7 +269,7 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBlockArea: cBlockArea::cBlockArea(void) : @@ -1759,7 +1759,7 @@ NIBBLETYPE cBlockArea::GetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBL -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBlockArea::cChunkReader: cBlockArea::cChunkReader::cChunkReader(cBlockArea & a_Area) : diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index 918781a00..5f1639d45 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -50,7 +50,7 @@ public: cItems Pickups; m_Contents.CopyToItems(Pickups); m_Contents.Clear(); - m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block + m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block } // tolua_begin diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 146ad915b..45f8a3e4d 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -11,7 +11,7 @@ #include "../CommandOutput.h" #include "../Root.h" -#include "../Server.h" // ExecuteConsoleCommand() +#include "../Server.h" // ExecuteConsoleCommand() #include "../Chunk.h" diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 108c2ce1b..0fa6bbe69 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 & 0x07) // Vanilla uses the 8th bit to determine power state - we don't + 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; @@ -90,7 +90,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) int SmokeDir = 0; switch (Meta) { - case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) + case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block) case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break; case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break; case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break; @@ -235,7 +235,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum) cItems Pickups; Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum)); - const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6 + const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6 int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0; switch (Meta) { @@ -249,7 +249,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum) double MicroX, MicroY, MicroZ; MicroX = DispX + 0.5; - MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser + MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser MicroZ = DispZ + 0.5; diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 7af4b9d5d..48d3b8dcc 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -219,7 +219,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) } Vector3f EntityPos = a_Entity->GetPosition(); - Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards + Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards double Distance = (EntityPos - BlockPos).Length(); if (Distance < 0.5) @@ -243,7 +243,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) { m_bFoundPickupsAbove = true; m_Contents.SetSlot(i, Item); - a_Pickup->Destroy(); // Kill pickup + a_Pickup->Destroy(); // Kill pickup return true; } @@ -253,11 +253,11 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick) int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; - Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added + Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added if (Item.IsEmpty()) { - a_Pickup->Destroy(); // Kill pickup if all items were added + a_Pickup->Destroy(); // Kill pickup if all items were added } return true; } diff --git a/src/BlockID.h b/src/BlockID.h index 4246c0bc9..997ee2cf9 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -399,7 +399,7 @@ enum // Please keep this list alpha-sorted by the blocktype / itemtype part // then number-sorted for the same block / item - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Block metas: // E_BLOCK_BIG_FLOWER metas @@ -678,7 +678,7 @@ enum E_META_WOOL_RED = 14, E_META_WOOL_BLACK = 15, - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Item metas: // E_ITEM_COAL metas: diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 6a3c6a55b..32b5133c7 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -122,16 +122,16 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface else { // Is foot end - VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken + VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken PillowDirection = MetaDataToDirection(Meta & 0x7); - if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping + if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping { a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z); } } - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x4); // Where 0x4 = occupied bit a_Player->SetIsInBed(true); cTimeFastForwardTester Tester; @@ -140,7 +140,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface cPlayerBedStateUnsetter Unsetter(Vector3i(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z), a_WorldInterface); a_WorldInterface.ForEachPlayer(Unsetter); a_WorldInterface.SetTimeOfDay(0); - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset } } } diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 7f92681dc..9fc5e4626 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -74,7 +74,7 @@ public: default: { ASSERT(!"Unhandled block face!"); - return 0x0; // No idea, give a special meta (button in centre of block) + return 0x0; // No idea, give a special meta (button in centre of block) } } } diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h index 4dd05366d..6caaaab13 100644 --- a/src/Blocks/BlockComparator.h +++ b/src/Blocks/BlockComparator.h @@ -22,7 +22,7 @@ public: virtual void OnUse(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) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR + Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); } diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index e2b3039fd..cf240fa60 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -43,8 +43,8 @@ public: // Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111 switch (a_Meta & 0x07) { - case 0x00: return 0x01 + OtherMeta; // Down -> Up - case 0x01: return 0x00 + OtherMeta; // Up -> Down + case 0x00: return 0x01 + OtherMeta; // Down -> Up + case 0x01: return 0x00 + OtherMeta; // Up -> Down } // Not Facing Up or Down; No change. return a_Meta; diff --git a/src/Blocks/BlockEnderchest.h b/src/Blocks/BlockEnderchest.h index 67955f8ce..4672f1459 100644 --- a/src/Blocks/BlockEnderchest.h +++ b/src/Blocks/BlockEnderchest.h @@ -18,7 +18,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - //todo: Drop Ender Chest if using silk touch pickaxe + // todo: Drop Ender Chest if using silk touch pickaxe a_Pickups.push_back(cItem(E_BLOCK_OBSIDIAN, 8, 0)); } diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 390b6e5ee..ed0592acd 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -106,7 +106,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta + a_Pickups.Add(E_BLOCK_DIRT, 1, 0); // Reset meta } } ; diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h index 147e4b53e..f52825362 100644 --- a/src/Blocks/BlockFire.h +++ b/src/Blocks/BlockFire.h @@ -100,7 +100,7 @@ public: /// Evaluates if coords have a valid border on top, based on MaxY bool EvaluatePortalBorder(int X, int FoundObsidianY, int Z, int MaxY, cChunkInterface & a_ChunkInterface) { - for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners + for (int checkBorder = FoundObsidianY + 1; checkBorder <= MaxY - 1; checkBorder++) // FoundObsidianY + 1: FoundObsidianY has already been checked in FindObsidianCeiling; MaxY - 1: portal doesn't need corners { if (a_ChunkInterface.GetBlock(X, checkBorder, Z) != E_BLOCK_OBSIDIAN) { @@ -115,10 +115,10 @@ public: /// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface) { - int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks - int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above + int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks + int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above - if (MaxY == 0) // Oh noes! Not a portal coordinate :( + if (MaxY == 0) // Oh noes! Not a portal coordinate :( { return; } @@ -127,11 +127,11 @@ public: { if (!FindPortalSliceZ(X, Y, Z1, Z2, MaxY, a_ChunkInterface)) { - return; // No eligible portal construct, abort abort abort!! + return; // No eligible portal construct, abort abort abort!! } } - for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks + for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks { for (int Width = XZM; Width <= XZP; Width++) { @@ -153,23 +153,23 @@ public: /// Takes coordinates of base block and Y coord of target obsidian ceiling bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface) { - Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction) + Dir = 1; // Set assumed direction (will change if portal turns out to be facing the other direction) bool FoundFrameXP = false, FoundFrameXM = false; - for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners + for (; ((a_ChunkInterface.GetBlock(X1, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X1, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X1++) // Check XP for obsidian blocks, exempting corners { int Value = FindObsidianCeiling(X1, Y, Z, a_ChunkInterface, MaxY); - int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian - if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find + int ValueTwo = FindObsidianCeiling(X1, Y + 1, Z, a_ChunkInterface, MaxY); // For corners without obsidian + if ((Value == -1) || (ValueTwo == -1)) // FindObsidianCeiling returns -1 upon frame-find { - FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further) + FoundFrameXP = true; // Found a frame border in this direction, proceed in other direction (don't go further) break; } - else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice' + else if ((Value != MaxY) && (ValueTwo != MaxY)) // Make sure that there is a valid portal 'slice' { - return false; // Not valid slice, no portal can be formed + return false; // Not valid slice, no portal can be formed } - } XZP = X1 - 1; // Set boundary of frame interior - for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM) + } XZP = X1 - 1; // Set boundary of frame interior + for (; ((a_ChunkInterface.GetBlock(X2, Y, Z) == E_BLOCK_OBSIDIAN) || (a_ChunkInterface.GetBlock(X2, Y + 1, Z) == E_BLOCK_OBSIDIAN)); X2--) // Go the other direction (XM) { int Value = FindObsidianCeiling(X2, Y, Z, a_ChunkInterface, MaxY); int ValueTwo = FindObsidianCeiling(X2, Y + 1, Z, a_ChunkInterface, MaxY); @@ -182,7 +182,7 @@ public: { return false; } - } XZM = X2 + 1; // Set boundary, see previous + } XZM = X2 + 1; // Set boundary, see previous return (FoundFrameXP && FoundFrameXM); } diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 120396c7d..2c41083e7 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -45,7 +45,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(m_BlockType, 1, 0); // Reset meta + a_Pickups.Add(m_BlockType, 1, 0); // Reset meta } diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 495e849fa..260abefc7 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -76,7 +76,7 @@ public: virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); - a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay } diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index ec480aaea..6ffb56abd 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -235,7 +235,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBlockPistonHeadHandler: cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) : @@ -262,7 +262,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInter a_ChunkInterface.DigBlock(a_WorldInterface, newX, newY, newZ); if (a_Player->IsGameModeCreative()) { - return; // No pickups if creative + return; // No pickups if creative } cItems Pickups; diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 1c8ac6a35..307539476 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -132,7 +132,7 @@ private: { if (cBlockInfo::IsPistonBreakable(a_BlockType)) { - return false; // CanBreakPush returns true, but we need false to prevent pulling + return false; // CanBreakPush returns true, but we need false to prevent pulling } return CanPush(a_BlockType, a_BlockMeta); diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index 3b8030028..d58b2f09d 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -36,7 +36,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - return; // No pickups + return; // No pickups } virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override @@ -57,7 +57,7 @@ public: { if ((a_RelY - 1 < 0) || (a_RelY + 1 > cChunkDef::Height)) { - return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 + return false; // In case someone places a portal with meta 1 or 2 at boundaries, and server tries to get invalid coords at Y - 1 or Y + 1 } switch (a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)) diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index 9cc51490f..1b1f6f9f0 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -25,7 +25,7 @@ public: { a_BlockType = m_BlockType; NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage); - if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block. + if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block. { a_BlockMeta = Meta; return true; @@ -42,25 +42,25 @@ public: case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_QuartzMeta; // Top or bottom, just return original + return a_QuartzMeta; // Top or bottom, just return original } case BLOCK_FACE_ZP: case BLOCK_FACE_ZM: { - return 0x4; // North or south + return 0x4; // North or south } case BLOCK_FACE_XP: case BLOCK_FACE_XM: { - return 0x3; // East or west + return 0x3; // East or west } default: { ASSERT(!"Unhandled block face!"); - return a_QuartzMeta; // No idea, give a special meta (all sides the same) + return a_QuartzMeta; // No idea, give a special meta (all sides the same) } } } diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index 358b5ca11..6f3fa1bd5 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -140,7 +140,7 @@ public: { NIBBLETYPE Meta = 0; char RailsCnt = 0; - bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP + bool Neighbors[8]; // 0 - EAST, 1 - WEST, 2 - NORTH, 3 - SOUTH, 4 - EAST UP, 5 - WEST UP, 6 - NORTH UP, 7 - SOUTH UP memset(Neighbors, 0, sizeof(Neighbors)); Neighbors[0] = (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN)); Neighbors[1] = (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN)); diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h index fe6cd21b9..4c8a6a087 100644 --- a/src/Blocks/BlockRedstoneRepeater.h +++ b/src/Blocks/BlockRedstoneRepeater.h @@ -71,7 +71,7 @@ public: inline static NIBBLETYPE RepeaterRotationToMetaData(double a_Rotation) { - a_Rotation += 90 + 45; // So its not aligned with axis + a_Rotation += 90 + 45; // So its not aligned with axis if (a_Rotation > 360) { a_Rotation -= 360; diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index 5b37efd75..9cbd4cf97 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -32,7 +32,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta + a_Pickups.Add(m_BlockType, 1, a_BlockMeta & 0x3); // Reset meta } @@ -43,25 +43,25 @@ public: case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_Meta; // 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_Meta | 0x8; // North or south + return a_Meta | 0x8; // North or south } case BLOCK_FACE_XP: case BLOCK_FACE_XM: { - return a_Meta | 0x4; // East or west + return a_Meta | 0x4; // East or west } default: { ASSERT(!"Unhandled block face!"); - return a_Meta | 0xC; // No idea, give a special meta + return a_Meta | 0xC; // No idea, give a special meta } } } diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index b21995d3c..c5ae4a5a6 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -47,12 +47,12 @@ public: { if ((a_Player->GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < 7)) { - return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored + return true; // If a player is holding a (thin) snow block and it's size can be increased, return collision ignored } if (a_Meta == 0) { - return true; // If at normal snowfall height (lowest), we ignore collision + return true; // If at normal snowfall height (lowest), we ignore collision } return false; diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index a49fda5ae..e74ab0094 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -85,7 +85,7 @@ public: static NIBBLETYPE RotationToMetaData(double a_Rotation) { - a_Rotation += 90 + 45; // So its not aligned with axis + a_Rotation += 90 + 45; // So its not aligned with axis if (a_Rotation > 360) { a_Rotation -= 360; diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 44c33c429..554ab8125 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -28,7 +28,7 @@ public: if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) { - a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face + a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face if (a_BlockFace == BLOCK_FACE_NONE) { // Client wouldn't have sent anything anyway, but whatever @@ -38,10 +38,10 @@ public: else { // Not top or bottom faces, try to preserve whatever face was clicked - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); // Set to clicked block if (!CanBePlacedOn(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace)) { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false); // Reset to torch block // Torch couldn't be placed on whatever face was clicked, last ditch resort - find another face a_BlockFace = FindSuitableFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); if (a_BlockFace == BLOCK_FACE_NONE) @@ -113,13 +113,13 @@ public: /// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions + for (int i = BLOCK_FACE_YM; i <= BLOCK_FACE_XP; i++) // Loop through all directions { eBlockFace Face = static_cast(i); AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true); BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if ( // If on a block that can only hold a torch if torch is standing on it, return that face + if ( // If on a block that can only hold a torch if torch is standing on it, return that face ((BlockInQuestion == E_BLOCK_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || @@ -158,7 +158,7 @@ public: (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_END_PORTAL_FRAME) || // Actual vanilla behaviour (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || (BlockInQuestion == E_BLOCK_COBBLESTONE_WALL) ) diff --git a/src/Blocks/MetaRotator.h b/src/Blocks/MetaRotator.h index 899c583e1..ad8f36183 100644 --- a/src/Blocks/MetaRotator.h +++ b/src/Blocks/MetaRotator.h @@ -6,7 +6,7 @@ // MSVC generates warnings for the templated AssertIfNotMatched parameter conditions, so disable it: #ifdef _MSC_VER - #pragma warning(disable: 4127) // Conditional expression is constant + #pragma warning(disable: 4127) // Conditional expression is constant #endif diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 1a69c856f..64b31c60b 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -140,7 +140,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cByteBuffer: cByteBuffer::cByteBuffer(size_t a_BufferSize) : diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 2d8ff7714..6fb615f1c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -41,7 +41,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // sSetBlock: sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) // absolute block position @@ -58,7 +58,7 @@ sSetBlock::sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_Bloc -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunk: cChunk::cChunk( diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp index 2425adf18..ebcf0e272 100644 --- a/src/ChunkSender.cpp +++ b/src/ChunkSender.cpp @@ -17,7 +17,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNotifyChunkSender: void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ) @@ -29,7 +29,7 @@ void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunkSender: cChunkSender::cChunkSender(void) : diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index afa99008a..97466c331 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -60,7 +60,7 @@ int cClientHandle::s_ClientCount = 0; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cClientHandle: cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : diff --git a/src/CommandOutput.cpp b/src/CommandOutput.cpp index 2c116b3d6..510461d81 100644 --- a/src/CommandOutput.cpp +++ b/src/CommandOutput.cpp @@ -10,7 +10,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCommandOutputCallback: void cCommandOutputCallback::Out(const char * a_Fmt, ...) @@ -28,7 +28,7 @@ void cCommandOutputCallback::Out(const char * a_Fmt, ...) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLogCommandOutputCallback: void cLogCommandOutputCallback::Out(const AString & a_Text) diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp index a3612983a..f1a797897 100644 --- a/src/CompositeChat.cpp +++ b/src/CompositeChat.cpp @@ -100,7 +100,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat: cCompositeChat::cCompositeChat(void) : @@ -399,7 +399,7 @@ void cCompositeChat::AddStyle(AString & a_Style, const AString & a_AddStyle) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cBasePart: cCompositeChat::cBasePart::cBasePart(cCompositeChat::ePartType a_PartType, const AString & a_Text, const AString & a_Style) : @@ -413,7 +413,7 @@ cCompositeChat::cBasePart::cBasePart(cCompositeChat::ePartType a_PartType, const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cTextPart: cCompositeChat::cTextPart::cTextPart(const AString & a_Text, const AString &a_Style) : @@ -425,7 +425,7 @@ cCompositeChat::cTextPart::cTextPart(const AString & a_Text, const AString &a_St -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cClientTranslatedPart: cCompositeChat::cClientTranslatedPart::cClientTranslatedPart(const AString & a_TranslationID, const AStringVector & a_Parameters, const AString & a_Style) : @@ -438,7 +438,7 @@ cCompositeChat::cClientTranslatedPart::cClientTranslatedPart(const AString & a_T -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cUrlPart: cCompositeChat::cUrlPart::cUrlPart(const AString & a_Text, const AString & a_Url, const AString & a_Style) : @@ -451,7 +451,7 @@ cCompositeChat::cUrlPart::cUrlPart(const AString & a_Text, const AString & a_Url -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cCommandPart: cCompositeChat::cCommandPart::cCommandPart(ePartType a_PartType, const AString & a_Text, const AString & a_Command, const AString & a_Style) : @@ -464,7 +464,7 @@ cCompositeChat::cCommandPart::cCommandPart(ePartType a_PartType, const AString & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cRunCommandPart: cCompositeChat::cRunCommandPart::cRunCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style) : @@ -475,7 +475,7 @@ cCompositeChat::cRunCommandPart::cRunCommandPart(const AString & a_Text, const A -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cSuggestCommandPart: cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text, const AString & a_Command, const AString & a_Style) : @@ -487,7 +487,7 @@ cCompositeChat::cSuggestCommandPart::cSuggestCommandPart(const AString & a_Text, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompositeChat::cShowAchievementPart: cCompositeChat::cShowAchievementPart::cShowAchievementPart(const AString & a_PlayerName, const AString & a_Achievement, const AString & a_Style) : diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index e9946160f..e60c407d0 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -12,7 +12,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingGrid: cCraftingGrid::cCraftingGrid(int a_Width, int a_Height) : @@ -206,7 +206,7 @@ void cCraftingGrid::Dump(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingRecipe: cCraftingRecipe::cCraftingRecipe(const cCraftingGrid & a_CraftingGrid) : @@ -259,7 +259,7 @@ void cCraftingRecipe::Dump(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingRecipes: cCraftingRecipes::cCraftingRecipes(void) diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp index 3e5240248..d97447412 100644 --- a/src/Cuboid.cpp +++ b/src/Cuboid.cpp @@ -21,7 +21,7 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCuboid: void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index a3a1667e4..c0e361fea 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -75,12 +75,12 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa { if (GetSpeed().EqualsEps(Vector3d(0, 0, 0), 0.0000001)) { - SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later + SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later } Vector3d Hit = a_HitPos; 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) + 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(); @@ -166,9 +166,9 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) // We can afford to do this because xoft's algorithm for trajectory is near perfect, so things are pretty close anyway without sync // Besides, this seems to be what the vanilla server does, note how arrows teleport half a second after they hit to the server position - if (!m_HasTeleported) // Sent a teleport already, don't do again + if (!m_HasTeleported) // Sent a teleport already, don't do again { - if (m_HitGroundTimer > 500.f) // Send after half 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; @@ -189,9 +189,9 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk) return; } - if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed? + if (Chunk->GetBlock(RelPosX, m_HitBlockPos.y, RelPosZ) == E_BLOCK_AIR) // Block attached to was destroyed? { - m_IsInGround = false; // Yes, begin simulating physics again + m_IsInGround = false; // Yes, begin simulating physics again } } } diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index 76cb24449..ad93dba6c 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -99,4 +99,4 @@ protected: virtual void CollectedBy(cPlayer * a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index 31bfe3dc3..2e9e77b44 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -94,7 +94,7 @@ void cBoat::Tick(float a_Dt, cChunk & a_Chunk) super::Tick(a_Dt, a_Chunk); BroadcastMovementUpdate(); - SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed + SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed if ((POSY_TOINT < 0) || (POSY_TOINT > cChunkDef::Height)) { diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c6dc1fca3..0a85537bf 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -272,7 +272,7 @@ void cEntity::SetYawFromSpeed(void) void cEntity::SetPitchFromSpeed(void) { const double EPS = 0.0000001; - double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component + double xz = sqrt(m_Speed.x * m_Speed.x + m_Speed.z * m_Speed.z); // Speed XZ-plane component if ((abs(xz) < EPS) && (abs(m_Speed.y) < EPS)) { // atan2() may overflow or is undefined, pick any number @@ -316,7 +316,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack)) { a_TDI.FinalDamage += 2; - m_World->BroadcastEntityAnimation(*this, 4); // Critical hit + m_World->BroadcastEntityAnimation(*this, 4); // Critical hit } } @@ -332,7 +332,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) m_Health = 0; } - if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs + 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) @@ -767,11 +767,11 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) NextSpeed.x *= 0.25; NextSpeed.z *= 0.25; } - - //Get water direction + + // Get water direction Direction WaterDir = m_World->GetWaterSimulator()->GetFlowingDirection(BlockX, BlockY, BlockZ); - m_WaterSpeed *= 0.9f; //Reduce speed each tick + m_WaterSpeed *= 0.9f; // Reduce speed each tick switch(WaterDir) { @@ -828,7 +828,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f; if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f; - if (Tracer.HitNormal.y == 1) // Hit BLOCK_FACE_YP, we are on the ground + if (Tracer.HitNormal.y == 1) // Hit BLOCK_FACE_YP, we are on the ground { m_bOnGround = true; } @@ -1095,9 +1095,9 @@ void cEntity::HandleAir(void) if (IsSubmerged()) { - if (!IsPlayer()) // Players control themselves + if (!IsPlayer()) // Players control themselves { - SetSpeedY(1); // Float in the water + SetSpeedY(1); // Float in the water } // Either reduce air level or damage player @@ -1266,9 +1266,9 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0)); int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0)); - if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved? + if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved? { - if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte + if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte { // Difference within Byte limitations, use a relative move packet if (m_bDirtyOrientation) @@ -1288,7 +1288,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) { // Too big a movement, do a teleport m_World->BroadcastTeleportEntity(*this, a_Exclude); - m_LastPos = GetPosition(); // See above + m_LastPos = GetPosition(); // See above m_bDirtyOrientation = false; } } @@ -1587,7 +1587,7 @@ void cEntity::SteerVehicle(float a_Forward, float a_Sideways) -////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Get look vector (this is NOT a rotation!) Vector3d cEntity::GetLookVector(void) const { @@ -1601,7 +1601,7 @@ Vector3d cEntity::GetLookVector(void) const -////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Set position void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) { diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index ea44c2722..011293233 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -506,7 +506,7 @@ protected: overrides can provide further processing, such as forcing players to move at the given speed. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); - virtual void Destroyed(void) {} // Called after the entity has been destroyed + virtual void Destroyed(void) {} // Called after the entity has been destroyed /** Called in each tick to handle air-related processing i.e. drowning */ virtual void HandleAir(void); diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp index 4da7cac85..6c4b13a58 100644 --- a/src/Entities/EntityEffect.cpp +++ b/src/Entities/EntityEffect.cpp @@ -108,7 +108,7 @@ void cEntityEffect::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectInstantHealth: void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) @@ -128,7 +128,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectInstantDamage: void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) @@ -148,7 +148,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectRegeneration: void cEntityEffectRegeneration::OnTick(cPawn & a_Target) @@ -175,7 +175,7 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectHunger: void cEntityEffectHunger::OnTick(cPawn & a_Target) @@ -193,7 +193,7 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectWeakness: void cEntityEffectWeakness::OnTick(cPawn & a_Target) @@ -211,7 +211,7 @@ void cEntityEffectWeakness::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectPoison: void cEntityEffectPoison::OnTick(cPawn & a_Target) @@ -250,7 +250,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectWither: void cEntityEffectWither::OnTick(cPawn & a_Target) @@ -270,7 +270,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target) -///////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEntityEffectSaturation: void cEntityEffectSaturation::OnTick(cPawn & a_Target) diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h index b2043d8f1..e9536452c 100644 --- a/src/Entities/ExpBottleEntity.h +++ b/src/Entities/ExpBottleEntity.h @@ -30,4 +30,4 @@ protected: // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h index 3924c337c..42ecc7d74 100644 --- a/src/Entities/FireChargeEntity.h +++ b/src/Entities/FireChargeEntity.h @@ -33,4 +33,4 @@ protected: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h index c62ca9402..7dbdc49e1 100644 --- a/src/Entities/FireworkEntity.h +++ b/src/Entities/FireworkEntity.h @@ -37,4 +37,4 @@ private: int m_ExplodeTimer; cItem m_FireworkItem; -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index d49893020..159429147 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -11,7 +11,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFloaterEntityCollisionCallback class cFloaterEntityCollisionCallback : public cEntityCallback @@ -75,7 +75,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFloaterCheckEntityExist class cFloaterCheckEntityExist : public cEntityCallback @@ -130,7 +130,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) HandlePhysics(a_Dt, a_Chunk); if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0) { - if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob. + if ((!m_CanPickupItem) && (m_AttachedMobID == -1)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob. { if (m_CountDownTime <= 0) { @@ -141,7 +141,7 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) m_CountDownTime = 100 + m_World->GetTickRandomNumber(800); LOGD("Floater %i can be picked up", GetUniqueID()); } - else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them. + else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them. { LOGD("Started producing particles for floater %i", GetUniqueID()); m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8))); @@ -156,12 +156,12 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) m_CountDownTime--; if (m_World->GetHeight((int) GetPosX(), (int) GetPosZ()) == (int) GetPosY()) { - if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on. + if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0) // 25% chance of an extra countdown when being rained on. { m_CountDownTime--; } } - else // if the floater is underground it has a 50% chance of not decreasing the countdown. + else // if the floater is underground it has a 50% chance of not decreasing the countdown. { if (m_World->GetTickRandomNumber(1) == 0) { @@ -190,21 +190,21 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk) if (Callback.HasHit()) { AttachTo(Callback.GetHitEntity()); - Callback.GetHitEntity()->TakeDamage(*this); // TODO: the player attacked the mob not the floater. + Callback.GetHitEntity()->TakeDamage(*this); // TODO: the player attacked the mob not the floater. m_AttachedMobID = Callback.GetHitEntity()->GetUniqueID(); } } cFloaterCheckEntityExist EntityCallback; m_World->DoWithEntityByID(m_PlayerID, EntityCallback); - if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity. + if (!EntityCallback.DoesExist()) // The owner doesn't exist anymore. Destroy the floater entity. { Destroy(true); } if (m_AttachedMobID != -1) { - m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore. + m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback); // The mob the floater was attached to doesn't exist anymore. if (!EntityCallback.DoesExist()) { m_AttachedMobID = -1; diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h index 547d503f1..5d2720b6a 100644 --- a/src/Entities/Floater.h +++ b/src/Entities/Floater.h @@ -14,7 +14,7 @@ class cFloater : typedef cEntity super; public: - //tolua_end + // tolua_end CLASS_PROTODEF(cFloater); @@ -43,4 +43,4 @@ protected: // Entity IDs int m_PlayerID; int m_AttachedMobID; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h index 9e4572c78..fa59fa642 100644 --- a/src/Entities/GhastFireballEntity.h +++ b/src/Entities/GhastFireballEntity.h @@ -35,4 +35,4 @@ protected: // TODO: Deflecting the fireballs by arrow- or sword- hits -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index 41ac86268..d7a7ba943 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -28,14 +28,14 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle) // The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces switch (m_BlockFace) { - case BLOCK_FACE_ZP: break; // Initialised to zero + case BLOCK_FACE_ZP: break; // Initialised to zero case BLOCK_FACE_ZM: Dir = 2; break; case BLOCK_FACE_XM: Dir = 1; break; case BLOCK_FACE_XP: Dir = 3; break; default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return; } - if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180 + if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180 { SetYaw((Dir * 90) - 180); } diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 4cd707faa..144c6d5aa 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -43,7 +43,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) } } - GetWorld()->BroadcastEntityMetadata(*this); // Update clients + GetWorld()->BroadcastEntityMetadata(*this); // Update clients } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 7bd440d6d..6502ae45a 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -117,7 +117,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) return; } } - a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart + a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart a_ClientHandle.SendEntityMetadata(*this); } @@ -127,7 +127,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk) { - if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead + if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead { return; } @@ -156,8 +156,8 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk) if (!IsBlockRail(InsideType)) { - Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this - if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards + Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this + if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards } bool WasDetectorRail = false; @@ -186,12 +186,12 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk) default: VERIFY(!"Unhandled rail type despite checking if block was rail!"); break; } - AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp + AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp } else { // Not on rail, default physics - SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail + SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail super::HandlePhysics(a_Dt, *Chunk); } @@ -223,18 +223,18 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) switch (a_RailMeta) { - case E_META_RAIL_ZM_ZP: // NORTHSOUTH + case E_META_RAIL_ZM_ZP: // NORTHSOUTH { SetYaw(270); SetPosY(floor(GetPosY()) + 0.55); - SetSpeedY(0); // Don't move vertically as on ground - SetSpeedX(0); // Correct diagonal movement from curved rails + SetSpeedY(0); // Don't move vertically as on ground + SetSpeedX(0); // Correct diagonal movement from curved rails // Execute both the entity and block collision checks bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta); if (EntCol || BlckCol) return; - if (GetSpeedZ() != 0) // Don't do anything if cart is stationary + if (GetSpeedZ() != 0) // Don't do anything if cart is stationary { if (GetSpeedZ() > 0) { @@ -249,7 +249,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_XM_XP: // EASTWEST + case E_META_RAIL_XM_XP: // EASTWEST { SetYaw(180); SetPosY(floor(GetPosY()) + 0.55); @@ -272,7 +272,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH + case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH { SetYaw(270); SetSpeedX(0); @@ -280,21 +280,21 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) if (GetSpeedZ() >= 0) { // SpeedZ POSITIVE, going SOUTH - if (GetSpeedZ() <= MAX_SPEED) // Speed limit + if (GetSpeedZ() <= MAX_SPEED) // Speed limit { - AddSpeedZ(0.5); // Speed up - SetSpeedY(-GetSpeedZ()); // Downward movement is negative (0 minus positive numbers is negative) + AddSpeedZ(0.5); // Speed up + SetSpeedY(-GetSpeedZ()); // Downward movement is negative (0 minus positive numbers is negative) } } else { // SpeedZ NEGATIVE, going NORTH - AddSpeedZ(1); // Slow down - SetSpeedY(-GetSpeedZ()); // Upward movement is positive (0 minus negative number is positive number) + AddSpeedZ(1); // Slow down + SetSpeedY(-GetSpeedZ()); // Upward movement is positive (0 minus negative number is positive number) } break; } - case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH + case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH { SetYaw(270); SetSpeedX(0); @@ -302,21 +302,21 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) if (GetSpeedZ() > 0) { // SpeedZ POSITIVE, going SOUTH - AddSpeedZ(-1); // Slow down - SetSpeedY(GetSpeedZ()); // Upward movement positive + AddSpeedZ(-1); // Slow down + SetSpeedY(GetSpeedZ()); // Upward movement positive } else { - if (GetSpeedZ() >= MAX_SPEED_NEGATIVE) // Speed limit + if (GetSpeedZ() >= MAX_SPEED_NEGATIVE) // Speed limit { // SpeedZ NEGATIVE, going NORTH - AddSpeedZ(-0.5); // Speed up - SetSpeedY(GetSpeedZ()); // Downward movement negative + AddSpeedZ(-0.5); // Speed up + SetSpeedY(GetSpeedZ()); // Downward movement negative } } break; } - case E_META_RAIL_ASCEND_XM: // ASCEND EAST + case E_META_RAIL_ASCEND_XM: // ASCEND EAST { SetYaw(180); SetSpeedZ(0); @@ -336,7 +336,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_ASCEND_XP: // ASCEND WEST + case E_META_RAIL_ASCEND_XP: // ASCEND WEST { SetYaw(180); SetSpeedZ(0); @@ -356,10 +356,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } break; } - case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST + case E_META_RAIL_CURVED_ZM_XM: // Ends pointing NORTH and WEST { - SetYaw(315); // Set correct rotation server side - SetPosY(floor(GetPosY()) + 0.55); // Levitate dat cart + SetYaw(315); // Set correct rotation server side + SetPosY(floor(GetPosY()) + 0.55); // Levitate dat cart SetSpeedY(0); TestBlockCollision(a_RailMeta); @@ -369,7 +369,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) break; } - case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST + case E_META_RAIL_CURVED_ZM_XP: // Curved NORTH EAST { SetYaw(225); SetPosY(floor(GetPosY()) + 0.55); @@ -380,7 +380,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) break; } - case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST + case E_META_RAIL_CURVED_ZP_XM: // Curved SOUTH WEST { SetYaw(135); SetPosY(floor(GetPosY()) + 0.55); @@ -391,7 +391,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) break; } - case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST + case E_META_RAIL_CURVED_ZP_XP: // Curved SOUTH EAST { SetYaw(45); SetPosY(floor(GetPosY()) + 0.55); @@ -404,7 +404,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt) } default: { - ASSERT(!"Unhandled rail meta!"); // Dun dun DUN! + ASSERT(!"Unhandled rail meta!"); // Dun dun DUN! break; } } @@ -428,7 +428,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) switch (a_RailMeta & 0x07) { - case E_META_RAIL_ZM_ZP: // NORTHSOUTH + case E_META_RAIL_ZM_ZP: // NORTHSOUTH { SetYaw(270); SetPosY(floor(GetPosY()) + 0.55); @@ -451,7 +451,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_XM_XP: // EASTWEST + case E_META_RAIL_XM_XP: // EASTWEST { SetYaw(180); SetPosY(floor(GetPosY()) + 0.55); @@ -474,7 +474,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_XM: // ASCEND EAST + case E_META_RAIL_ASCEND_XM: // ASCEND EAST { SetYaw(180); SetSpeedZ(0); @@ -494,7 +494,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_XP: // ASCEND WEST + case E_META_RAIL_ASCEND_XP: // ASCEND WEST { SetYaw(180); SetSpeedZ(0); @@ -514,7 +514,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH + case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH { SetYaw(270); SetSpeedX(0); @@ -534,7 +534,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } break; } - case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH + case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH { SetYaw(270); SetSpeedX(0); @@ -907,7 +907,7 @@ bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative()) { Destroy(); - TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative + TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative SetInvulnerableTicks(0); return super::DoTakeDamage(TDI); // No drops for creative } @@ -980,7 +980,7 @@ void cMinecart::Destroyed() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRideableMinecart: cRideableMinecart::cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height) : @@ -1023,7 +1023,7 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithChest: cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) : @@ -1056,7 +1056,7 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithFurnace: cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) : @@ -1078,12 +1078,12 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player) { a_Player.GetInventory().RemoveOneEquippedItem(); } - if (!m_IsFueled) // We don't want to change the direction by right clicking it. + if (!m_IsFueled) // We don't want to change the direction by right clicking it. { AddSpeed(a_Player.GetLookVector().x, 0, a_Player.GetLookVector().z); } m_IsFueled = true; - m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks. + m_FueledTimeLeft = m_FueledTimeLeft + 600; // The minecart will be active 600 more ticks. m_World->BroadcastEntityMetadata(*this); } } @@ -1118,7 +1118,7 @@ void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithTNT: cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : @@ -1132,7 +1132,7 @@ cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMinecartWithHopper: cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) : diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h index 30af6d412..ce7c6f3de 100644 --- a/src/Entities/Painting.h +++ b/src/Entities/Painting.h @@ -18,8 +18,8 @@ public: CLASS_PROTODEF(cPainting); cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z); - const AString & GetName(void) const { return m_Name; } // tolua_export - int GetDirection(void) const { return m_Direction; } // tolua_export + const AString & GetName(void) const { return m_Name; } // tolua_export + int GetDirection(void) const { return m_Direction; } // tolua_export private: diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index bae1485d4..ab0f856dd 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -113,7 +113,7 @@ void cPickup::SpawnOn(cClientHandle & a_Client) void cPickup::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - BroadcastMovementUpdate(); //Notify clients of position + BroadcastMovementUpdate(); // Notify clients of position m_Timer += a_Dt; @@ -150,10 +150,10 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) } } - if (!IsDestroyed() && (m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine into an already full pickup + 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 + m_World->ForEachEntity(PickupCombiningCallback); // Not ForEachEntityInChunk, otherwise pickups don't combine across chunk boundaries if (PickupCombiningCallback.FoundMatchingPickup()) { m_World->BroadcastEntityMetadata(*this); @@ -176,7 +176,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) return; } - if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible! + if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible! { Destroy(true); return; @@ -194,14 +194,14 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) if (m_bCollected) { // LOG("Pickup %d cannot be collected by \"%s\", because it has already been collected.", m_UniqueID, a_Dest->GetName().c_str()); - return false; // It's already collected! + return false; // It's already collected! } // Two seconds if player created the pickup (vomiting), half a second if anything else if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f)) { // LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str()); - return false; // Not old enough + return false; // Not old enough } if (cRoot::Get()->GetPluginManager()->CallHookCollectingPickup(a_Dest, *this)) diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index 2dcbecaaf..d50941280 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -27,7 +27,7 @@ public: cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); - cItem & GetItem(void) {return m_Item; } // tolua_export + cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } virtual void SpawnOn(cClientHandle & a_ClientHandle) override; @@ -46,7 +46,7 @@ public: bool IsCollected(void) const { return m_bCollected; } // tolua_export /** Returns true if created by player (i.e. vomiting), used for determining picking-up delay time */ - bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export + bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export private: diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index da50843b6..c4f9c59ab 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -223,7 +223,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) SendExperience(); } - if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible 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(); @@ -284,19 +284,19 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) short cPlayer::CalcLevelFromXp(short a_XpTotal) { - //level 0 to 15 + // level 0 to 15 if(a_XpTotal <= XP_TO_LEVEL15) { return a_XpTotal / XP_PER_LEVEL_TO15; } - //level 30+ + // level 30+ if(a_XpTotal > XP_TO_LEVEL30) { return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7; } - //level 16 to 30 + // level 16 to 30 return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3; } @@ -306,19 +306,19 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal) short cPlayer::XpForLevel(short a_Level) { - //level 0 to 15 + // level 0 to 15 if(a_Level <= 15) { return a_Level * XP_PER_LEVEL_TO15; } - //level 30+ + // level 30+ if(a_Level >= 31) { return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 ); } - //level 16 to 30 + // level 16 to 30 return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 ); } @@ -353,7 +353,7 @@ bool cPlayer::SetCurrentExperience(short int a_CurrentXp) if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp))) { LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp); - return false; //oops, they gave us a dodgey number + return false; // oops, they gave us a dodgey number } m_CurrentXp = a_CurrentXp; @@ -375,7 +375,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) // Value was bad, abort and report LOGWARNING("Attempt was made to increment Xp by %d, which overflowed the short datatype. Ignoring.", a_Xp_delta); - return -1; // Should we instead just return the current Xp? + return -1; // Should we instead just return the current Xp? } m_CurrentXp += a_Xp_delta; @@ -477,7 +477,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) { float Dist = (float)(m_LastGroundHeight - floor(GetPosY())); - if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above + if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above { // Increment statistic m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5)); @@ -623,7 +623,7 @@ void cPlayer::FinishEating(void) GetInventory().RemoveOneEquippedItem(); - //if the food is mushroom soup, return a bowl to the inventory + // if the food is mushroom soup, return a bowl to the inventory if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) { cItem emptyBowl(E_ITEM_BOWL, 1, 0, ""); GetInventory().AddItem(emptyBowl, true, true); @@ -871,10 +871,10 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) if (m_Health > 0) { - return; // not dead yet =] + return; // not dead yet =] } - m_bVisible = false; // So new clients don't see the player + m_bVisible = false; // So new clients don't see the player // Puke out all the items cItems Pickups; @@ -925,7 +925,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) else { AString KillerClass = a_TDI.Attacker->GetClass(); - KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") + 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())); } @@ -1338,7 +1338,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) void cPlayer::SetVisible(bool a_bVisible) { - if (a_bVisible && !m_bVisible) // Make visible + if (a_bVisible && !m_bVisible) // Make visible { m_bVisible = true; m_World->BroadcastSpawnEntity(*this); @@ -1420,7 +1420,7 @@ bool cPlayer::HasPermission(const AString & a_Permission) { if( OtherSplit[i].compare( Split[i] ) != 0 ) { - if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! + if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard! break; } } @@ -1548,7 +1548,7 @@ void cPlayer::TossEquippedItem(char a_Amount) char NewAmount = a_Amount; if (NewAmount > GetInventory().GetEquippedItem().m_ItemCount) { - NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there + NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there } GetInventory().GetHotbarGrid().ChangeSlotCount(GetInventory().GetEquippedSlotNum() /* Returns hotbar subslot, which HotbarGrid takes */, -a_Amount); @@ -1610,7 +1610,7 @@ void cPlayer::TossItems(const cItems & a_Items) double vX = 0, vY = 0, vZ = 0; EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player + m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player } @@ -1931,7 +1931,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() void cPlayer::UseEquippedItem(void) { - if (IsGameModeCreative()) // No damage in creative + if (IsGameModeCreative()) // No damage in creative { return; } @@ -2074,7 +2074,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) { if (IsClimbing()) { - if (a_DeltaPos.y > 0.0) // Going up + if (a_DeltaPos.y > 0.0) // Going up { m_Stats.AddValue(statDistClimbed, (StatValue)floor(a_DeltaPos.y * 100 + 0.5)); } @@ -2093,7 +2093,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) } else { - if (Value >= 25) // Ignore small/slow movement + if (Value >= 25) // Ignore small/slow movement { m_Stats.AddValue(statDistFlown, Value); } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 793f11e57..171e9541b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -174,7 +174,7 @@ public: AString GetIP(void) const { return m_IP; } // tolua_export /** Returns the associated team, NULL if none */ - cTeam * GetTeam(void) { return m_Team; } // tolua_export + cTeam * GetTeam(void) { return m_Team; } // tolua_export /** Sets the player team, NULL if none */ void SetTeam(cTeam * a_Team); @@ -200,7 +200,7 @@ public: /** Forces the player to move in the given direction. @deprecated Use SetSpeed instead. */ - void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export + void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export @@ -570,7 +570,7 @@ protected: /** 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 +} ; // tolua_export diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 019ebeaa5..a55c9b895 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -35,7 +35,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProjectileTracerCallback: class cProjectileTracerCallback : @@ -122,7 +122,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProjectileEntityCollisionCallback: class cProjectileEntityCollisionCallback : @@ -211,7 +211,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProjectileEntity: cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) : diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 14cee1272..7b045de76 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -120,4 +120,4 @@ protected: virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; virtual void SpawnOn(cClientHandle & a_Client) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index ed5afaf11..3efb1f25d 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -7,7 +7,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntityCallback: /** Used to distribute the splashed potion effect among nearby entities */ @@ -63,7 +63,7 @@ private: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntity: cSplashPotionEntity::cSplashPotionEntity( diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 076e477da..2c78b55d2 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -56,4 +56,4 @@ protected: /** 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); -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h index 116f5a8cb..df61b14f5 100644 --- a/src/Entities/TNTEntity.h +++ b/src/Entities/TNTEntity.h @@ -38,7 +38,7 @@ public: protected: int m_FuseTicks; ///< How much ticks is left, while the tnt will explode -}; // tolua_export +}; // tolua_export diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index dc72c279f..f93731256 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -55,4 +55,4 @@ private: /** Time in ticks to wait for the hit animation to begin before destroying */ int m_DestroyTimer; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index 1cea5f7d9..549d8a3eb 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -55,4 +55,4 @@ private: /** Time in ticks to wait for the hit animation to begin before destroying */ int m_DestroyTimer; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index 9a8770379..6f3efdd7e 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -52,4 +52,4 @@ private: /** Time in ticks to wait for the hit animation to begin before destroying */ int m_DestroyTimer; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h index 8b3639802..ebc1550e3 100644 --- a/src/Entities/WitherSkullEntity.h +++ b/src/Entities/WitherSkullEntity.h @@ -32,4 +32,4 @@ protected: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; -} ; // tolua_export +} ; // tolua_export diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index a17555f37..d314fc13e 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -12,7 +12,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBiomeGen: cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault) @@ -78,7 +78,7 @@ cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenConstant: void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -108,7 +108,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenCache: cBioGenCache::cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize) : @@ -209,7 +209,7 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBiomeGenList: void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) @@ -290,7 +290,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenCheckerboard: void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -324,7 +324,7 @@ void cBioGenCheckerboard::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenVoronoi : void cBioGenVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -357,7 +357,7 @@ void cBioGenVoronoi::InitializeBiomeGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenDistortedVoronoi: void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) @@ -418,7 +418,7 @@ void cBioGenDistortedVoronoi::Distort(int a_BlockX, int a_BlockZ, int & a_Distor -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenMultiStepMap : cBioGenMultiStepMap::cBioGenMultiStepMap(int a_Seed) : @@ -739,7 +739,7 @@ void cBioGenMultiStepMap::FreezeWaterBiomes(cChunkDef::BiomeMap & a_BiomeMap, co -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBioGenTwoLevel: cBioGenTwoLevel::cBioGenTwoLevel(int a_Seed) : diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index 6aa7fd4cb..f543846d2 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -151,7 +151,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCaveTunnel: cCaveTunnel::cCaveTunnel( @@ -571,7 +571,7 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves::cCaveSystem: cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxOffset, int a_Size, cNoise & a_Noise) : @@ -687,7 +687,7 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenWormNestCaves: cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) @@ -700,7 +700,7 @@ cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_Gri -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenMarbleCaves: static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) @@ -752,7 +752,7 @@ void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenDualRidgeCaves: void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc) diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 73f0223e8..3f8f77f09 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -22,7 +22,7 @@ const unsigned int QUEUE_SKIP_LIMIT = 500; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunkGenerator: cChunkGenerator::cChunkGenerator(void) : @@ -290,7 +290,7 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChunkGenerator::cGenerator: cChunkGenerator::cGenerator::cGenerator(cChunkGenerator & a_ChunkGenerator) : diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 2da285d72..160d095ed 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -18,7 +18,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenSameBlock: void cCompoGenSameBlock::ComposeTerrain(cChunkDesc & a_ChunkDesc) @@ -60,7 +60,7 @@ void cCompoGenSameBlock::InitializeCompoGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenDebugBiomes: void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) @@ -111,7 +111,7 @@ void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenClassic: cCompoGenClassic::cCompoGenClassic(void) : @@ -209,7 +209,7 @@ void cCompoGenClassic::InitializeCompoGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenBiomal: void cCompoGenBiomal::ComposeTerrain(cChunkDesc & a_ChunkDesc) @@ -526,7 +526,7 @@ void cCompoGenBiomal::FillColumnPattern(int a_RelX, int a_RelZ, int a_Height, cC -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenNether: cCompoGenNether::cCompoGenNether(int a_Seed) : @@ -645,7 +645,7 @@ void cCompoGenNether::InitializeCompoGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCompoGenCache: cCompoGenCache::cCompoGenCache(cTerrainCompositionGen & a_Underlying, int a_CacheSize) : diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 7b6234161..167fbab37 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -34,7 +34,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTerrainCompositionGen: cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed) @@ -114,7 +114,7 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cComposableGenerator: cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) : diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index eb9fe92ba..b46850a81 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -14,7 +14,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPattern: /// This class is used to store a column pattern initialized at runtime, @@ -50,7 +50,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // The arrays to use for the top block pattern definitions: static cDistortedHeightmap::sBlockInfo tbGrass[] = @@ -119,7 +119,7 @@ static cDistortedHeightmap::sBlockInfo tbStone[] = -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Ocean floor pattern top-block definitions: static cDistortedHeightmap::sBlockInfo tbOFSand[] = @@ -151,7 +151,7 @@ static cDistortedHeightmap::sBlockInfo tbOFRedSand[] = -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Individual patterns to use: static cPattern patGrass (tbGrass, ARRAYCOUNT(tbGrass)); @@ -171,7 +171,7 @@ static cPattern patOFRedSand(tbOFRedSand, ARRAYCOUNT(tbOFRedSand)); -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDistortedHeightmap: /** This table assigns a relative maximum overhang size in each direction to biomes. diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index f466039b9..abbf050f7 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -29,7 +29,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEndGen: cEndGen::cEndGen(int a_Seed) : diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index f2d66af70..dd1ab045d 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -40,12 +40,12 @@ static inline bool IsWater(BLOCKTYPE a_BlockType) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenNetherClumpFoliage: void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc) { - double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. + double ChunkX = a_ChunkDesc.GetChunkX() + 0.1; // We can't devide through 0 so lets add 0.1 to all the chunk coordinates. double ChunkZ = a_ChunkDesc.GetChunkZ() + 0.1; NOISE_DATATYPE Val1 = m_Noise.CubicNoise2D((float) (ChunkX * ChunkZ * 0.01f), (float) (ChunkZ / ChunkX * 0.01f)); @@ -125,7 +125,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a float zz = (float) a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; for (int y = a_RelY - 2; y < a_RelY + 2; y++) { - if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. + if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) // Don't replace non air blocks. { continue; } @@ -136,7 +136,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a continue; } - if (IsFireBlock) // don't place fire on non-forever burning blocks. + if (IsFireBlock) // don't place fire on non-forever burning blocks. { if (!cFireSimulator::DoesBurnForever(BlockBelow)) { @@ -159,7 +159,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenSprinkleFoliage: bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ) @@ -309,7 +309,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenSnow: void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc) @@ -345,7 +345,7 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenIce: void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) @@ -385,7 +385,7 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenLilypads: int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) @@ -447,7 +447,7 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenBottomLava: void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc) @@ -470,7 +470,7 @@ void cFinishGenBottomLava::GenFinish(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenPreSimulator: cFinishGenPreSimulator::cFinishGenPreSimulator(void) @@ -637,7 +637,7 @@ void cFinishGenPreSimulator::StationarizeFluid( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFinishGenFluidSprings: cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension) : diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index fd1d5e49f..7090f14b1 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -9,7 +9,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEmptyStructure: /** A cStructure descendant representing an empty structure. diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 202f7db7e..537e30a31 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -16,7 +16,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTerrainHeightGen: cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault) @@ -91,7 +91,7 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenFlat: void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) @@ -115,7 +115,7 @@ void cHeiGenFlat::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenCache: cHeiGenCache::cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, int a_CacheSize) : @@ -234,7 +234,7 @@ bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_Rel -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenClassic: cHeiGenClassic::cHeiGenClassic(int a_Seed) : @@ -255,7 +255,7 @@ float cHeiGenClassic::GetNoise(float x, float y) float height = m_Noise.CubicNoise2D(x * 0.1f, y * 0.1f ) * 2; - float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5 + float flatness = ((m_Noise.CubicNoise2D(x * 0.5f, y * 0.5f) + 1.f) * 0.5f) * 1.1f; // 0 ... 1.5 flatness *= flatness * flatness; return (oct1 + oct2 + oct3) * flatness + height; @@ -306,7 +306,7 @@ void cHeiGenClassic::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenMountains: cHeiGenMountains::cHeiGenMountains(int a_Seed) : @@ -368,7 +368,7 @@ void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHeiGenBiomal: const cHeiGenBiomal::sGenParam cHeiGenBiomal::m_GenParam[256] = diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index ab9b1aa29..e951b90fa 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -275,7 +275,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenMineShafts::cMineShaftSystem: cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( @@ -400,7 +400,7 @@ bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_Boundin -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftDirtRoom: cMineShaftDirtRoom::cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise) : @@ -492,7 +492,7 @@ void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftCorridor: cMineShaftCorridor::cMineShaftCorridor( @@ -732,7 +732,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc) PlaceChest(a_ChunkDesc); PlaceTracks(a_ChunkDesc); - PlaceSpawner(a_ChunkDesc); // (must be after Tracks!) + PlaceSpawner(a_ChunkDesc); // (must be after Tracks!) PlaceTorches(a_ChunkDesc); } @@ -964,7 +964,7 @@ void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftCrossing: cMineShaftCrossing::cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox) : @@ -1100,7 +1100,7 @@ void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMineShaftStaircase: cMineShaftStaircase::cMineShaftStaircase( @@ -1278,7 +1278,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenMineShafts: cStructGenMineShafts::cStructGenMineShafts( diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index 23fa56048..f35555efd 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -11,7 +11,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNetherFortGen::cNetherFort: class cNetherFortGen::cNetherFort : @@ -65,7 +65,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Performance test of the NetherFort generator: /* @@ -99,7 +99,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNetherFortGen: cPrefabPiecePool cNetherFortGen::m_PiecePool(g_NetherFortPrefabs, g_NetherFortPrefabsCount, g_NetherFortStartingPrefabs, g_NetherFortStartingPrefabsCount); diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 15a588d45..b879349ee 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -61,7 +61,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNoise3DGenerator: cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) : @@ -342,7 +342,7 @@ void cNoise3DGenerator::ComposeTerrain(cChunkDesc & a_ChunkDesc) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNoise3DComposable: cNoise3DComposable::cNoise3DComposable(int a_Seed) : diff --git a/src/Generating/POCPieceGenerator.cpp b/src/Generating/POCPieceGenerator.cpp index 491f4d206..6e7e74d7a 100644 --- a/src/Generating/POCPieceGenerator.cpp +++ b/src/Generating/POCPieceGenerator.cpp @@ -150,7 +150,7 @@ static void DebugPieces(const cPlacedPieces & a_Pieces) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPOCPieceGenerator: cPOCPieceGenerator::cPOCPieceGenerator(int a_Seed) : diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 5de231f75..fe1005dba 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -13,7 +13,7 @@ #ifdef SELF_TEST -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Self-test: static class cPieceGeneratorSelfTest : @@ -140,7 +140,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPiece: @@ -254,7 +254,7 @@ cCuboid cPiece::RotateMoveHitBox(int a_NumCCWRotations, int a_MoveX, int a_MoveY -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPiece::cConnector: cPiece::cConnector::cConnector(int a_X, int a_Y, int a_Z, int a_Type, eBlockFace a_Direction) : @@ -279,7 +279,7 @@ cPiece::cConnector::cConnector(const Vector3i & a_Pos, int a_Type, eBlockFace a_ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPlacedPiece: cPlacedPiece::cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece, const Vector3i & a_Coords, int a_NumCCWRotations) : @@ -328,7 +328,7 @@ void cPlacedPiece::MoveToGroundBy(int a_OffsetY) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPieceGenerator: cPieceGenerator::cPieceGenerator(cPiecePool & a_PiecePool, int a_Seed) : @@ -578,7 +578,7 @@ void cPieceGenerator::DebugConnectorPool(const cPieceGenerator::cFreeConnectors -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPieceGenerator::cConnection: cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations, int a_Weight) : @@ -593,7 +593,7 @@ cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPieceGenerator::cFreeConnector: cPieceGenerator::cFreeConnector::cFreeConnector(cPlacedPiece * a_Piece, const cPiece::cConnector & a_Connector) : @@ -606,7 +606,7 @@ cPieceGenerator::cFreeConnector::cFreeConnector(cPlacedPiece * a_Piece, const cP -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cBFSPieceGenerator: cBFSPieceGenerator::cBFSPieceGenerator(cPiecePool & a_PiecePool, int a_Seed) : diff --git a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp index 976f8490e..8c935c2a5 100644 --- a/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp +++ b/src/Generating/Prefabs/AlchemistVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BarWithBasement: // The data has been exported from the gallery Desert, area index 82, ID 598, created by STR_Warrior { @@ -264,7 +264,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BarWithoutBasement: // The data has been exported from the gallery Desert, area index 81, ID 597, created by STR_Warrior { @@ -463,7 +463,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BlackSmith: // The data has been exported from the gallery Desert, area index 97, ID 642, created by STR_Warrior { @@ -633,7 +633,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LargeHouse1: // The data has been exported from the gallery Desert, area index 77, ID 577, created by STR_Warrior { @@ -922,7 +922,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LargeTower: // The data has been exported from the gallery Desert, area index 80, ID 596, created by STR_Warrior { @@ -1108,7 +1108,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse: // The data has been exported from the gallery Desert, area index 65, ID 551, created by STR_Warrior { @@ -1229,7 +1229,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse2: // The data has been exported from the gallery Desert, area index 72, ID 562, created by STR_Warrior { @@ -1376,7 +1376,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse3: // The data has been exported from the gallery Desert, area index 66, ID 553, created by STR_Warrior { @@ -1496,7 +1496,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse4: // The data has been exported from the gallery Desert, area index 70, ID 560, created by STR_Warrior { @@ -1647,7 +1647,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse5: // The data has been exported from the gallery Desert, area index 68, ID 558, created by STR_Warrior { @@ -1781,7 +1781,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse6: // The data has been exported from the gallery Desert, area index 69, ID 559, created by STR_Warrior { @@ -1922,7 +1922,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse7: // The data has been exported from the gallery Desert, area index 73, ID 563, created by xoft { @@ -2068,7 +2068,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleHouse8: // The data has been exported from the gallery Desert, area index 99, ID 739, created by STR_Warrior { @@ -2200,7 +2200,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LittleTower: // The data has been exported from the gallery Desert, area index 79, ID 595, created by STR_Warrior { @@ -2351,7 +2351,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumHouse1: // The data has been exported from the gallery Desert, area index 71, ID 561, created by STR_Warrior { @@ -2531,7 +2531,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumHouse2: // The data has been exported from the gallery Desert, area index 74, ID 573, created by STR_Warrior { @@ -2740,7 +2740,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumHouse3: // The data has been exported from the gallery Desert, area index 76, ID 575, created by STR_Warrior { @@ -2958,7 +2958,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SmallHouse9: // The data has been exported from the gallery Desert, area index 67, ID 556, created by STR_Warrior { @@ -3104,7 +3104,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Temple: // The data has been exported from the gallery Desert, area index 83, ID 599, created by STR_Warrior { @@ -3310,7 +3310,7 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] = const cPrefab::sDef g_AlchemistVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 90, ID 631, created by STR_Warrior { diff --git a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp index d22153d87..c49015e36 100644 --- a/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp +++ b/src/Generating/Prefabs/JapaneseVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Arch: // The data has been exported from the gallery Plains, area index 144, ID 488, created by Aloe_vera { @@ -129,7 +129,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Farm: // The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera { @@ -299,7 +299,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Plains, area index 79, ID 145, created by Aloe_vera { @@ -565,7 +565,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Garden2: // The data has been exported from the gallery Plains, area index 147, ID 491, created by Aloe_vera { @@ -717,7 +717,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseMid: // The data has been exported from the gallery Plains, area index 62, ID 119, created by Aloe_vera { @@ -893,7 +893,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmall: // The data has been exported from the gallery Plains, area index 68, ID 131, created by Aloe_vera { @@ -1004,7 +1004,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmallDblWithDoor: // The data has been exported from the gallery Plains, area index 113, ID 265, created by Aloe_vera { @@ -1128,7 +1128,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmallDouble: // The data has been exported from the gallery Plains, area index 72, ID 135, created by Aloe_vera { @@ -1249,7 +1249,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseSmallWithDoor: // The data has been exported from the gallery Plains, area index 112, ID 264, created by Aloe_vera { @@ -1362,7 +1362,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWide: // The data has been exported from the gallery Plains, area index 64, ID 121, created by STR_Warrior { @@ -1510,7 +1510,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWithGarden: // The data has been exported from the gallery Plains, area index 67, ID 130, created by Aloe_vera { @@ -1756,7 +1756,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWithSakura1: // The data has been exported from the gallery Plains, area index 75, ID 141, created by Aloe_vera { @@ -1950,7 +1950,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseWithSpa: // The data has been exported from the gallery Plains, area index 73, ID 139, created by Aloe_vera { @@ -2158,7 +2158,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MediumSakuraTree: // The data has been exported from the gallery Plains, area index 146, ID 490, created by STR_Warrior { @@ -2312,7 +2312,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Restaurant: // The data has been exported from the gallery Plains, area index 61, ID 117, created by Aloe_vera { @@ -2566,7 +2566,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SakuraDouble: // The data has been exported from the gallery Plains, area index 76, ID 142, created by Aloe_vera { @@ -2697,7 +2697,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SakuraSmall: // The data has been exported from the gallery Plains, area index 145, ID 489, created by Aloe_vera { @@ -2808,7 +2808,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] = const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HighTemple: // The data has been exported from the gallery Plains, area index 70, ID 133, created by Aloe_vera { @@ -3159,7 +3159,7 @@ const cPrefab::sDef g_JapaneseVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Plains, area index 143, ID 487, created by STR_Warrior { diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index 2c97f28ea..ee3a8899b 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BalconyCorridor: // The data has been exported from the gallery Nether, area index 37, ID 288, created by Aloe_vera { @@ -162,7 +162,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BalconyTee2: // The data has been exported from the gallery Nether, area index 38, ID 289, created by Aloe_vera { @@ -325,7 +325,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BlazePlatform: // The data has been exported from the gallery Nether, area index 26, ID 276, created by tonibm1999 { @@ -448,7 +448,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BlazePlatformOverhang: // The data has been exported from the gallery Nether, area index 20, ID 162, created by STR_Warrior { @@ -621,7 +621,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCircleCrossing: // The data has been exported from the gallery Nether, area index 49, ID 308, created by Aloe_vera { @@ -824,7 +824,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCrossing: // The data has been exported from the gallery Nether, area index 17, ID 159, created by Aloe_vera { @@ -1028,7 +1028,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCrumble1: // The data has been exported from the gallery Nether, area index 19, ID 161, created by Aloe_vera { @@ -1125,7 +1125,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeCrumble2: // The data has been exported from the gallery Nether, area index 18, ID 160, created by Aloe_vera { @@ -1228,7 +1228,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeDoubleCrumble: // The data has been exported from the gallery Nether, area index 46, ID 305, created by STR_Warrior { @@ -1410,7 +1410,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeFunnelDown: // The data has been exported from the gallery Nether, area index 0, ID 2, created by Aloe_vera { @@ -1653,7 +1653,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeLevelCrossing: // The data has been exported from the gallery Nether, area index 61, ID 321, created by Aloe_vera { @@ -1985,7 +1985,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeSegment: // The data has been exported from the gallery Nether, area index 16, ID 158, created by Aloe_vera { @@ -2107,7 +2107,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BridgeTee: // The data has been exported from the gallery Nether, area index 39, ID 290, created by STR_Warrior { @@ -2270,7 +2270,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor11: // The data has been exported from the gallery Nether, area index 36, ID 287, created by Aloe_vera { @@ -2374,7 +2374,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor13: // The data has been exported from the gallery Nether, area index 35, ID 286, created by Aloe_vera { @@ -2478,7 +2478,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor5: // The data has been exported from the gallery Nether, area index 65, ID 330, created by xoft { @@ -2576,7 +2576,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCorner5: // The data has been exported from the gallery Nether, area index 10, ID 40, created by xoft { @@ -2718,7 +2718,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCornerChest5: // The data has been exported from the gallery Nether, area index 42, ID 293, created by STR_Warrior { @@ -2861,7 +2861,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCrossing: // The data has been exported from the gallery Nether, area index 63, ID 328, created by xoft { @@ -2989,7 +2989,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorStairs: // The data has been exported from the gallery Nether, area index 12, ID 42, created by xoft { @@ -3144,7 +3144,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DarkCorridor: // The data has been exported from the gallery Nether, area index 3, ID 30, created by STR_Warrior { @@ -3248,7 +3248,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LavaStaircase: // The data has been exported from the gallery Nether, area index 28, ID 278, created by Aloe_vera { @@ -3508,7 +3508,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LavaStaircaseBig: // The data has been exported from the gallery Nether, area index 31, ID 282, created by STR_Warrior { @@ -3842,7 +3842,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LavaStairsBridge: // The data has been exported from the gallery Nether, area index 30, ID 281, created by STR_Warrior { @@ -4123,7 +4123,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MidStaircase: // The data has been exported from the gallery Nether, area index 23, ID 165, created by Aloe_vera { @@ -4314,7 +4314,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StairsToOpen1: // The data has been exported from the gallery Nether, area index 27, ID 277, created by Aloe_vera { @@ -4460,7 +4460,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StairsToOpen2: // The data has been exported from the gallery Nether, area index 8, ID 35, created by xoft { @@ -4606,7 +4606,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Tee2x4: // The data has been exported from the gallery Nether, area index 40, ID 291, created by Aloe_vera { @@ -4726,7 +4726,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Tee4x4: // The data has been exported from the gallery Nether, area index 41, ID 292, created by Aloe_vera { @@ -4858,7 +4858,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // TinyCorridorCorner: // The data has been exported from the gallery Nether, area index 66, ID 331, created by xoft { @@ -4957,7 +4957,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // TinyCorridorCornerChest: // The data has been exported from the gallery Nether, area index 67, ID 332, created by Aloe_vera { @@ -5057,7 +5057,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // TinyCorridorCrossing: // The data has been exported from the gallery Nether, area index 64, ID 329, created by xoft { @@ -5159,7 +5159,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Turret: // The data has been exported from the gallery Nether, area index 7, ID 34, created by xoft { @@ -5283,7 +5283,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = const cPrefab::sDef g_NetherFortStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CentralRoom: // The data has been exported from the gallery Nether, area index 22, ID 164, created by Aloe_vera { diff --git a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp index bad8dae74..714a66559 100644 --- a/src/Generating/Prefabs/PlainsVillagePrefabs.cpp +++ b/src/Generating/Prefabs/PlainsVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BigPlantBed: // The data has been exported from the gallery Plains, area index 26, ID 70, created by Taugrammaton { @@ -195,7 +195,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CobbleHouse10x5Library: // The data has been exported from the gallery Plains, area index 23, ID 66, created by xoft { @@ -336,7 +336,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DoublePlantBed: // The data has been exported from the gallery Plains, area index 5, ID 20, created by tonibm1999 { @@ -492,7 +492,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Plains, area index 51, ID 102, created by Aloe_vera { @@ -692,7 +692,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // LampPost: // The data has been exported from the gallery Plains, area index 28, ID 73, created by STR_Warrior { @@ -784,7 +784,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftCorridor: // The data has been exported from the gallery Plains, area index 139, ID 447, created by STR_Warrior { @@ -861,7 +861,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftCrossing: // The data has been exported from the gallery Plains, area index 171, ID 578, created by Aloe_vera { @@ -946,7 +946,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftCrossing: // The data has been exported from the gallery Plains, area index 193, ID 657, created by Aloe_vera { @@ -1064,7 +1064,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftDoubleCrossing: // The data has been exported from the gallery Plains, area index 172, ID 579, created by Aloe_vera { @@ -1189,7 +1189,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftSpiral: // The data has been exported from the gallery Plains, area index 198, ID 662, created by Aloe_vera { @@ -1370,7 +1370,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftStairs: // The data has been exported from the gallery Plains, area index 195, ID 659, created by Aloe_vera { @@ -1469,7 +1469,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftStairsCrossing: // The data has been exported from the gallery Plains, area index 199, ID 663, created by Aloe_vera { @@ -1719,7 +1719,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftTee: // The data has been exported from the gallery Plains, area index 194, ID 658, created by Aloe_vera { @@ -1819,7 +1819,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineshaftsCorridor5: // The data has been exported from the gallery Plains, area index 200, ID 664, created by Aloe_vera { @@ -1898,7 +1898,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Scarecrow: // The data has been exported from the gallery Plains, area index 150, ID 494, created by STR_Warrior { @@ -1983,7 +1983,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SinglePlantBed: // The data has been exported from the gallery Plains, area index 17, ID 60, created by Aloe_vera { @@ -2108,7 +2108,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenChurchMid: // The data has been exported from the gallery Plains, area index 58, ID 109, created by Aloe_vera { @@ -2418,7 +2418,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenGranary: // The data has been exported from the gallery Plains, area index 54, ID 105, created by Aloe_vera { @@ -2560,7 +2560,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse10x7Library: // The data has been exported from the gallery Plains, area index 47, ID 98, created by Aloe_vera { @@ -2729,7 +2729,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse5x5: // The data has been exported from the gallery Plains, area index 49, ID 100, created by Aloe_vera { @@ -2856,7 +2856,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse7x5: // The data has been exported from the gallery Plains, area index 40, ID 91, created by xoft { @@ -2983,7 +2983,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5: // The data has been exported from the gallery Plains, area index 41, ID 92, created by xoft { @@ -3117,7 +3117,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5Fence: // The data has been exported from the gallery Plains, area index 9, ID 26, created by Aloe_vera { @@ -3287,7 +3287,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x5Library: // The data has been exported from the gallery Plains, area index 46, ID 97, created by Aloe_vera { @@ -3428,7 +3428,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7: // The data has been exported from the gallery Plains, area index 52, ID 103, created by Aloe_vera { @@ -3590,7 +3590,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7Butcher: // The data has been exported from the gallery Plains, area index 48, ID 99, created by Aloe_vera { @@ -3806,7 +3806,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouse9x7DoubleDoor: // The data has been exported from the gallery Plains, area index 38, ID 87, created by Aloe_vera { @@ -3971,7 +3971,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseL13x14: // The data has been exported from the gallery Plains, area index 39, ID 90, created by STR_Warrior { @@ -4223,7 +4223,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseL14x14: // The data has been exported from the gallery Plains, area index 0, ID 4, created by Aloe_vera { @@ -4450,7 +4450,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseL9x9: // The data has been exported from the gallery Plains, area index 42, ID 93, created by xoft { @@ -4619,7 +4619,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenHouseU13x9: // The data has been exported from the gallery Plains, area index 43, ID 94, created by xoft { @@ -4786,7 +4786,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenMill5x5: // The data has been exported from the gallery Plains, area index 60, ID 111, created by Aloe_vera { @@ -5121,7 +5121,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WoodenStables: // The data has been exported from the gallery Plains, area index 55, ID 106, created by Aloe_vera { @@ -5307,7 +5307,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] = const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CobbleWell4x4: // The data has been exported from the gallery Plains, area index 1, ID 5, created by Aloe_vera { @@ -5448,7 +5448,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MineEntrance: // The data has been exported from the gallery Plains, area index 138, ID 446, created by STR_Warrior { @@ -5897,7 +5897,7 @@ const cPrefab::sDef g_PlainsVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // RoofedWell: // The data has been exported from the gallery Plains, area index 119, ID 271, created by STR_Warrior { diff --git a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp index 1a3765c5a..bf7b1b096 100644 --- a/src/Generating/Prefabs/RainbowRoadPrefabs.cpp +++ b/src/Generating/Prefabs/RainbowRoadPrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveDouble: // The data has been exported from the gallery Cube, area index 89, ID 467, created by Aloe_vera { @@ -85,7 +85,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveDownFromTopSingle: // The data has been exported from the gallery Cube, area index 100, ID 478, created by Aloe_vera { @@ -255,7 +255,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveSingle: // The data has been exported from the gallery Cube, area index 84, ID 462, created by Aloe_vera { @@ -320,7 +320,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveSingleLeft: // The data has been exported from the gallery Cube, area index 97, ID 475, created by Aloe_vera { @@ -385,7 +385,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveUpDouble: // The data has been exported from the gallery Cube, area index 92, ID 470, created by Aloe_vera { @@ -581,7 +581,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CurveUpSingle: // The data has been exported from the gallery Cube, area index 87, ID 465, created by Aloe_vera { @@ -751,7 +751,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SlopeDownFromTopSingle: // The data has been exported from the gallery Cube, area index 98, ID 476, created by Aloe_vera { @@ -881,7 +881,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SlopeUpDouble: // The data has been exported from the gallery Cube, area index 90, ID 468, created by Aloe_vera { @@ -1061,7 +1061,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SlopeUpSingle: // The data has been exported from the gallery Cube, area index 85, ID 463, created by Aloe_vera { @@ -1191,7 +1191,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SplitTee: // The data has been exported from the gallery Cube, area index 93, ID 471, created by Aloe_vera { @@ -1261,7 +1261,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StraightDouble: // The data has been exported from the gallery Cube, area index 88, ID 466, created by Aloe_vera { @@ -1335,7 +1335,7 @@ const cPrefab::sDef g_RainbowRoadPrefabs[] = const cPrefab::sDef g_RainbowRoadStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // StraightSingle: // The data has been exported from the gallery Cube, area index 83, ID 461, created by Aloe_vera { diff --git a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp index 44e947952..3328ee210 100644 --- a/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandFlatRoofVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Forge: // The data has been exported from the gallery Desert, area index 32, ID 173, created by Aloe_vera { @@ -162,7 +162,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House11x7: // The data has been exported from the gallery Desert, area index 31, ID 172, created by Aloe_vera { @@ -301,7 +301,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House5x4: // The data has been exported from the gallery Desert, area index 25, ID 166, created by Aloe_vera { @@ -412,7 +412,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House5x5: // The data has been exported from the gallery Desert, area index 26, ID 167, created by Aloe_vera { @@ -530,7 +530,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House7x5: // The data has been exported from the gallery Desert, area index 27, ID 168, created by Aloe_vera { @@ -648,7 +648,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House8x5: // The data has been exported from the gallery Desert, area index 28, ID 169, created by Aloe_vera { @@ -772,7 +772,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House8x7: // The data has been exported from the gallery Desert, area index 29, ID 170, created by Aloe_vera { @@ -910,7 +910,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House9x7: // The data has been exported from the gallery Desert, area index 30, ID 171, created by Aloe_vera { @@ -1049,7 +1049,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseL13x12: // The data has been exported from the gallery Desert, area index 53, ID 345, created by jakibaki { @@ -1220,7 +1220,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // MarketStall: // The data has been exported from the gallery Desert, area index 34, ID 175, created by Aloe_vera { @@ -1330,7 +1330,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Marketplace: // The data has been exported from the gallery Desert, area index 38, ID 261, created by Aloe_vera { @@ -1472,7 +1472,7 @@ const cPrefab::sDef g_SandFlatRoofVillagePrefabs[] = const cPrefab::sDef g_SandFlatRoofVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 44, ID 275, created by Aloe_vera { diff --git a/src/Generating/Prefabs/SandVillagePrefabs.cpp b/src/Generating/Prefabs/SandVillagePrefabs.cpp index 72881a678..c63f8161b 100644 --- a/src/Generating/Prefabs/SandVillagePrefabs.cpp +++ b/src/Generating/Prefabs/SandVillagePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DoubleField: // The data has been exported from the gallery Desert, area index 5, ID 75, created by tonibm1999 { @@ -102,7 +102,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House11x7: // The data has been exported from the gallery Desert, area index 6, ID 81, created by Aloe_vera { @@ -236,7 +236,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House11x9: // The data has been exported from the gallery Desert, area index 11, ID 115, created by xoft { @@ -395,7 +395,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House13x7: // The data has been exported from the gallery Desert, area index 15, ID 125, created by Aloe_vera { @@ -527,7 +527,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House13x9: // The data has been exported from the gallery Desert, area index 12, ID 116, created by xoft { @@ -686,7 +686,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House15x9: // The data has been exported from the gallery Desert, area index 13, ID 118, created by xoft { @@ -845,7 +845,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House16x9: // The data has been exported from the gallery Desert, area index 16, ID 126, created by Aloe_vera { @@ -1004,7 +1004,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House7x7: // The data has been exported from the gallery Desert, area index 8, ID 112, created by Aloe_vera { @@ -1128,7 +1128,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House9x7: // The data has been exported from the gallery Desert, area index 9, ID 113, created by xoft { @@ -1253,7 +1253,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // House9x9: // The data has been exported from the gallery Desert, area index 10, ID 114, created by xoft { @@ -1404,7 +1404,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseL14x12: // The data has been exported from the gallery Desert, area index 14, ID 124, created by Aloe_vera { @@ -1592,7 +1592,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // HouseL14x12: // The data has been exported from the gallery Desert, area index 7, ID 82, created by Aloe_vera { @@ -1763,7 +1763,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SingleField: // The data has been exported from the gallery Desert, area index 17, ID 127, created by Aloe_vera { @@ -1844,7 +1844,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // SmallHut: // The data has been exported from the gallery Desert, area index 4, ID 68, created by tonibm1999 { @@ -1955,7 +1955,7 @@ const cPrefab::sDef g_SandVillagePrefabs[] = const cPrefab::sDef g_SandVillageStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // RoofedWell: // The data has been exported from the gallery Desert, area index 43, ID 274, created by Aloe_vera { @@ -2155,7 +2155,7 @@ const cPrefab::sDef g_SandVillageStartingPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Well: // The data has been exported from the gallery Desert, area index 0, ID 1, created by Aloe_vera { diff --git a/src/Generating/Prefabs/TestRailsPrefabs.cpp b/src/Generating/Prefabs/TestRailsPrefabs.cpp index 3444cb1fa..f58b95225 100644 --- a/src/Generating/Prefabs/TestRailsPrefabs.cpp +++ b/src/Generating/Prefabs/TestRailsPrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ActivatorRail: // The data has been exported from the gallery Plains, area index 251, ID 746, created by Aloe_vera { @@ -104,7 +104,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // DetectorRail: // The data has been exported from the gallery Plains, area index 250, ID 745, created by Aloe_vera { @@ -193,7 +193,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // PowerRail: // The data has been exported from the gallery Plains, area index 248, ID 743, created by Aloe_vera { @@ -284,7 +284,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // RegularRail: // The data has been exported from the gallery Plains, area index 247, ID 742, created by Aloe_vera { @@ -383,7 +383,7 @@ const cPrefab::sDef g_TestRailsPrefabs[] = const cPrefab::sDef g_TestRailsStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CentralPiece: // The data has been exported from the gallery Plains, area index 249, ID 744, created by Aloe_vera { diff --git a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp index 691d8aa9d..1655f50b9 100644 --- a/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp +++ b/src/Generating/Prefabs/UnderwaterBasePrefabs.cpp @@ -15,7 +15,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // BrokenRoom: // The data has been exported from the gallery Water, area index 49, ID 680, created by STR_Warrior { @@ -178,7 +178,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // Corridor16: // The data has been exported from the gallery Water, area index 25, ID 566, created by xoft { @@ -265,7 +265,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCorner: // The data has been exported from the gallery Water, area index 26, ID 569, created by xoft { @@ -380,7 +380,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorCrossing: // The data has been exported from the gallery Water, area index 31, ID 581, created by LO1ZB { @@ -526,7 +526,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorStairs: // The data has been exported from the gallery Water, area index 32, ID 582, created by LO1ZB { @@ -656,7 +656,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CorridorTee: // The data has been exported from the gallery Water, area index 29, ID 576, created by LO1ZB { @@ -775,7 +775,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCorner: // The data has been exported from the gallery Water, area index 40, ID 613, created by LO1ZB { @@ -958,7 +958,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCorridor: // The data has been exported from the gallery Water, area index 27, ID 571, created by LO1ZB { @@ -1065,7 +1065,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCorridorBulge: // The data has been exported from the gallery Water, area index 42, ID 615, created by LO1ZB { @@ -1280,7 +1280,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingCrossing: // The data has been exported from the gallery Water, area index 38, ID 611, created by LO1ZB { @@ -1483,7 +1483,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingEnd: // The data has been exported from the gallery Water, area index 41, ID 614, created by LO1ZB { @@ -1648,7 +1648,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // ViewingTee: // The data has been exported from the gallery Water, area index 39, ID 612, created by LO1ZB { @@ -1850,7 +1850,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // WaterfallRoom: // The data has been exported from the gallery Water, area index 50, ID 681, created by Aloe_vera { @@ -2059,7 +2059,7 @@ const cPrefab::sDef g_UnderwaterBasePrefabs[] = const cPrefab::sDef g_UnderwaterBaseStartingPrefabs[] = { - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// // CentralRoom: // The data has been exported from the gallery Water, area index 24, ID 564, created by xoft { diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp index 3b0ff7df8..c3c07cdec 100644 --- a/src/Generating/RainbowRoadsGen.cpp +++ b/src/Generating/RainbowRoadsGen.cpp @@ -18,7 +18,7 @@ static cPrefabPiecePool g_RainbowRoads(g_RainbowRoadPrefabs, g_RainbowRoadPrefab -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRainbowRoadsGen::cRainbowRoads: class cRainbowRoadsGen::cRainbowRoads : @@ -86,7 +86,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRainbowRoadsGen: diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 24f2cc3ab..8f62669e7 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -77,7 +77,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenRavines: cStructGenRavines::cStructGenRavines(int a_Seed, int a_Size) : @@ -101,7 +101,7 @@ cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_GridX, in -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenRavines::cRavine cStructGenRavines::cRavine::cRavine(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_Size, cNoise & a_Noise) : diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 636364e17..2e41243d6 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -12,7 +12,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenOreNests configuration: const int MAX_HEIGHT_COAL = 127; @@ -51,7 +51,7 @@ const int NEST_SIZE_GRAVEL = 32; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenTrees: void cStructGenTrees::GenFinish(cChunkDesc & a_ChunkDesc) @@ -303,7 +303,7 @@ int cStructGenTrees::GetNumTrees( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenOreNests: void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc) @@ -410,7 +410,7 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenLakes: void cStructGenLakes::GenFinish(cChunkDesc & a_ChunkDesc) @@ -532,7 +532,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenDirectOverhangs: cStructGenDirectOverhangs::cStructGenDirectOverhangs(int a_Seed) : @@ -648,7 +648,7 @@ bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cStructGenDistortedMembraneOverhangs: cStructGenDistortedMembraneOverhangs::cStructGenDistortedMembraneOverhangs(int a_Seed) : diff --git a/src/Generating/TestRailsGen.cpp b/src/Generating/TestRailsGen.cpp index c40c1a9b6..66ab8b33f 100644 --- a/src/Generating/TestRailsGen.cpp +++ b/src/Generating/TestRailsGen.cpp @@ -18,7 +18,7 @@ static cPrefabPiecePool g_TestRails(g_TestRailsPrefabs, g_TestRailsPrefabsCount, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTestRailsGen::cTestRails: class cTestRailsGen::cTestRails : @@ -86,7 +86,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cTestRailsGen: diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 522f45148..7478be69b 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -66,7 +66,7 @@ static const sCoords BigO3[] = {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, } ; -static const sCoords BigO4[] = // Part of Big Jungle tree +static const sCoords BigO4[] = // Part of Big Jungle tree { {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4}, {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3}, @@ -773,10 +773,10 @@ void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_LogBlocks.reserve(Height); a_OtherBlocks.reserve( - 2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x - 2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x - ARRAYCOUNT(BigO1) + 1 + // Plus on the top - Height * ARRAYCOUNT(Vines) + // Vines + 2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x + 2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x + ARRAYCOUNT(BigO1) + 1 + // Plus on the top + Height * ARRAYCOUNT(Vines) + // Vines 50 // some safety ); diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp index d3abae9b7..9278ea546 100644 --- a/src/Generating/UnderwaterBaseGen.cpp +++ b/src/Generating/UnderwaterBaseGen.cpp @@ -18,7 +18,7 @@ static cPrefabPiecePool g_UnderwaterBase(g_UnderwaterBasePrefabs, g_UnderwaterBa -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cUnderwaterBaseGen::cUnderwaterBase: class cUnderwaterBaseGen::cUnderwaterBase : @@ -86,7 +86,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cUnderwaterBaseGen: diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 2b7ecc837..fdec2425d 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -333,7 +333,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cVillageGen: static cVillagePiecePool g_SandVillage(g_SandVillagePrefabs, g_SandVillagePrefabsCount, g_SandVillageStartingPrefabs, g_SandVillageStartingPrefabsCount); diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp index 44feda469..f7e8f5f30 100644 --- a/src/HTTPServer/HTTPMessage.cpp +++ b/src/HTTPServer/HTTPMessage.cpp @@ -20,7 +20,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPMessage: cHTTPMessage::cHTTPMessage(eKind a_Kind) : @@ -64,7 +64,7 @@ void cHTTPMessage::AddHeader(const AString & a_Key, const AString & a_Value) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPRequest: cHTTPRequest::cHTTPRequest(void) : @@ -248,7 +248,7 @@ void cHTTPRequest::OnHeaderLine(const AString & a_Key, const AString & a_Value) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPResponse: cHTTPResponse::cHTTPResponse(void) : diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index 036b2e042..b7edf7829 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -118,7 +118,7 @@ class cDebugCallbacks : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHTTPServer: cHTTPServer::cHTTPServer(void) : diff --git a/src/HTTPServer/MultipartParser.cpp b/src/HTTPServer/MultipartParser.cpp index 309495dd7..09732c5f7 100644 --- a/src/HTTPServer/MultipartParser.cpp +++ b/src/HTTPServer/MultipartParser.cpp @@ -21,7 +21,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // self-test: #if 0 @@ -87,7 +87,7 @@ ThisIsIgnoredEpilogue"; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMultipartParser: diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp index f16ea1915..b345fef88 100644 --- a/src/HTTPServer/NameValueParser.cpp +++ b/src/HTTPServer/NameValueParser.cpp @@ -69,7 +69,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNameValueParser: cNameValueParser::cNameValueParser(bool a_AllowsKeyOnly) : diff --git a/src/Item.cpp b/src/Item.cpp index b3ce32336..876abafd0 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -375,7 +375,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cItems: cItem * cItems::Get(int a_Idx) diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index a733bda19..4cdfab0fe 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -49,7 +49,7 @@ public: Vector3i BlockPos; if (!GetBlockFromTrace(a_World, a_Player, BlockPos)) { - return false; // Nothing in range. + return false; // Nothing in range. } if (a_World->GetBlockMeta(BlockPos.x, BlockPos.y, BlockPos.z) != 0) @@ -160,7 +160,7 @@ public: { if (IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType)) { - if (a_BlockMeta != 0) // GetBlockFromTrace is called for scooping up fluids; the hit block should be a source + if (a_BlockMeta != 0) // GetBlockFromTrace is called for scooping up fluids; the hit block should be a source { return false; } diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 3b1ad1717..435d8ccf4 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -17,13 +17,15 @@ -///////////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////////////// // cFloaterCallback class cFloaterCallback : public cEntityCallback { public: - cFloaterCallback(void) : + cFloaterCallback(void) : m_CanPickup(false), m_AttachedMobID(-1) { @@ -49,8 +51,13 @@ protected: Vector3d m_Pos; } ; -//////////////////////////////////////////////////////////////////////////// -// cSweepEntityCallback + + + + +//////////////////////////////////////////////////////////////////////////////// +// cSweepEntityCallback: + class cSweepEntityCallback : public cEntityCallback { @@ -73,6 +80,8 @@ protected: + + class cItemFishingRodHandler : public cItemHandler { @@ -106,19 +115,19 @@ public: { cItems Drops; int ItemCategory = a_World->GetTickRandomNumber(99); - if (ItemCategory <= 4) // Treasures 5% + if (ItemCategory <= 4) // Treasures 5% { int Treasure = a_World->GetTickRandomNumber(5); switch (Treasure) { case 0: { - Drops.Add(cItem(E_ITEM_BOW)); // TODO: Enchantments + Drops.Add(cItem(E_ITEM_BOW)); // TODO: Enchantments break; } case 1: { - Drops.Add(cItem(E_ITEM_BOOK)); // TODO: Enchanted book + Drops.Add(cItem(E_ITEM_BOOK)); // TODO: Enchanted book break; } case 2: @@ -237,3 +246,7 @@ public: return true; } } ; + + + + diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 85406c826..c261ce0e8 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -362,7 +362,7 @@ char cItemHandler::GetMaxStackSize(void) return 64; } - switch (m_ItemType) //sorted by id + switch (m_ItemType) { case E_ITEM_ARROW: return 64; case E_ITEM_BAKED_POTATO: return 64; @@ -568,7 +568,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(600); // Give the player food poisoning for 30 seconds. + a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds. } } diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index cffca11ab..b33671c2d 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -60,7 +60,7 @@ public: { double Saturation; int FoodLevel; - int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning + int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning FoodInfo(int a_FoodLevel, double a_Saturation, int a_PoisonChance = 0) : Saturation(a_Saturation), @@ -112,11 +112,11 @@ public: protected: int m_ItemType; - static cItemHandler *CreateItemHandler(int m_ItemType); + static cItemHandler * CreateItemHandler(int m_ItemType); static cItemHandler * m_ItemHandler[E_ITEM_LAST + 1]; - static bool m_HandlerInitialized; //used to detect if the itemhandlers are initialized + static bool m_HandlerInitialized; // used to detect if the itemhandlers are initialized }; -//Short function +// Short function inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); } diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index b258b4aea..87e20ecf0 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -27,9 +27,9 @@ public: return false; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again if (Block == E_BLOCK_AIR) { diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h index 12cb45d1c..0ed6e5e0e 100644 --- a/src/Items/ItemLeaves.h +++ b/src/Items/ItemLeaves.h @@ -31,7 +31,7 @@ public: a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); - a_BlockMeta = a_BlockMeta | 0x4; //0x4 bit set means this is a player-placed leaves block, not to be decayed + a_BlockMeta = a_BlockMeta | 0x4; // 0x4 bit set means this is a player-placed leaves block, not to be decayed return res; } } ; diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index bc650cdbd..b9d837384 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -25,7 +25,7 @@ public: virtual bool IsPlaceable(void) override { - return false; // Set as not placeable so OnItemUse is called + return false; // Set as not placeable so OnItemUse is called } @@ -57,7 +57,7 @@ public: { if (IsBlockWater(a_CBBlockType)) { - if ((a_CBBlockMeta != 0) || (a_CBEntryFace == BLOCK_FACE_NONE)) // The hit block should be a source. The FACE_NONE check is clicking whilst submerged + if ((a_CBBlockMeta != 0) || (a_CBEntryFace == BLOCK_FACE_NONE)) // The hit block should be a source. The FACE_NONE check is clicking whilst submerged { return false; } diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h index e4bb76ebe..a2a77ce21 100644 --- a/src/Items/ItemPainting.h +++ b/src/Items/ItemPainting.h @@ -27,9 +27,9 @@ public: return false; } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again if (Block == E_BLOCK_AIR) { @@ -38,14 +38,14 @@ public: // The client uses different values for painting directions and block faces. Our constants are for the block faces, so we convert them here to painting faces switch (a_Dir) { - case BLOCK_FACE_ZP: break; // Initialised to zero + case BLOCK_FACE_ZP: break; // Initialised to zero case BLOCK_FACE_ZM: Dir = 2; break; case BLOCK_FACE_XM: Dir = 1; break; case BLOCK_FACE_XP: Dir = 3; break; default: ASSERT(!"Unhandled block face when trying spawn painting!"); return false; } - static const struct // Define all the possible painting titles + static const struct // Define all the possible painting titles { AString Title; } gPaintingTitlesList[] = diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index 274d905a5..33e386b03 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -27,7 +27,7 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { - if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust + if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust { return false; } diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 7283edcee..53f5d51c3 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -25,7 +25,7 @@ public: virtual bool IsFood(void) override { - switch (m_ItemType) // Special cases, both a seed and food + switch (m_ItemType) // Special cases, both a seed and food { case E_ITEM_CARROT: case E_ITEM_POTATO: return true; diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 403a3e097..3fbbee6b5 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -84,7 +84,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLightingThread: cLightingThread::cLightingThread(void) : @@ -582,7 +582,7 @@ void cLightingThread::QueueChunkStay(cLightingChunkStay & a_ChunkStay) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cLightingThread::cLightingChunkStay: cLightingThread::cLightingChunkStay::cLightingChunkStay(cLightingThread & a_LightingThread, int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_CallbackAfter) : diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp index ad2029589..78eb19f3e 100644 --- a/src/MCLogger.cpp +++ b/src/MCLogger.cpp @@ -227,7 +227,7 @@ void cMCLogger::ResetColor(void) -////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Global functions void LOG(const char* a_Format, ...) diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 8ab09a4c5..495f1dd25 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -43,7 +43,7 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) if (m_ExplodingTimer == 30) { m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this); - Destroy(); // Just in case we aren't killed by the explosion + Destroy(); // Just in case we aren't killed by the explosion } } } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index e36634c73..9e53284b3 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -62,7 +62,7 @@ static const struct -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cMonster: cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) @@ -120,7 +120,7 @@ void cMonster::TickPathFinding() std::vector m_PotentialCoordinates; m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ)); - static const struct // Define which directions to try to move to + static const struct // Define which directions to try to move to { int x, z; } gCrossCoords[] = @@ -301,12 +301,12 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) if (DoesPosYRequireJump((int)floor(m_Destination.y))) { m_bOnGround = false; - AddSpeedY(5.2); // Jump!! + AddSpeedY(5.2); // Jump!! } } Vector3f Distance = m_Destination - GetPosition(); - if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move + if(!ReachedDestination() && !ReachedFinalDestination()) // If we haven't reached any sort of destination, move { Distance.y = 0; Distance.Normalize(); @@ -325,20 +325,20 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) AddSpeedZ(Distance.z); if (m_EMState == ESCAPING) - { //Runs Faster when escaping :D otherwise they just walk away + { // Runs Faster when escaping :D otherwise they just walk away SetSpeedX (GetSpeedX() * 2.f); SetSpeedZ (GetSpeedZ() * 2.f); } } else { - if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate + if (ReachedFinalDestination()) // If we have reached the ultimate, final destination, stop pathfinding and attack if appropriate { FinishPathFinding(); } else { - TickPathFinding(); // We have reached the next point in our path, calculate another point + TickPathFinding(); // We have reached the next point in our path, calculate another point } } } @@ -570,8 +570,8 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI) -//Checks to see if EventSeePlayer should be fired -//monster sez: Do I see the player +// Checks to see if EventSeePlayer should be fired +// monster sez: Do I see the player void cMonster::CheckEventSeePlayer(void) { // TODO: Rewrite this to use cWorld's DoWithPlayers() @@ -631,7 +631,7 @@ void cMonster::InStateIdle(float a_Dt) { if (m_bMovingToDestination) { - return; // Still getting there + return; // Still getting there } m_IdleInterval += a_Dt; @@ -640,7 +640,7 @@ void cMonster::InStateIdle(float a_Dt) { // At this interval the results are predictable int rem = m_World->GetTickRandomNumber(6) + 1; - m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds + m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds Vector3d Dist; Dist.x = (double)m_World->GetTickRandomNumber(10) - 5; @@ -928,7 +928,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) case mtWitch: toReturn = new cWitch(); break; case mtWither: toReturn = new cWither(); break; case mtWolf: toReturn = new cWolf(); break; - case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter + case mtZombie: toReturn = new cZombie(false); break; // TODO: Infected zombie parameter case mtZombiePigman: toReturn = new cZombiePigman(); break; default: { diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 59bcdaa37..96e73b45b 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -61,13 +61,13 @@ public: enum eFamily { - mfHostile = 0, // Spider, Zombies ... - mfPassive = 1, // Cows, Pigs - mfAmbient = 2, // Bats - mfWater = 3, // Squid + mfHostile = 0, // Spider, Zombies ... + mfPassive = 1, // Cows, Pigs + mfAmbient = 2, // Bats + mfWater = 3, // Squid mfNoSpawn, - mfUnhandled, // Nothing. Be sure this is the last and the others are in order + mfUnhandled, // Nothing. Be sure this is the last and the others are in order } ; // tolua_end @@ -93,7 +93,7 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void MoveToPosition(const Vector3f & a_Position); - virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export + virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual bool ReachedDestination(void); // tolua_begin @@ -265,7 +265,7 @@ protected: void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel); -} ; // tolua_export +} ; // tolua_export diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 019f9e6a2..7335848b7 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -93,12 +93,12 @@ void cSheep::Tick(float a_Dt, cChunk & a_Chunk) if (m_TimeToStopEating > 0) { - m_bMovingToDestination = false; // The sheep should not move when he's eating + m_bMovingToDestination = false; // The sheep should not move when he's eating m_TimeToStopEating--; if (m_TimeToStopEating == 0) { - if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime + if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime { // The sheep ate the grass so we change it to dirt m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0); diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 41283acf4..d183a338f 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -138,8 +138,8 @@ void cVillager::HandleFarmerPrepareFarmCrops() m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5); MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5))); return; - } // for Y loop. - } // Repeat the procces 5 times. + } // for Y loop. + } // Repeat the procces 5 times. } diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h index abde48407..068dfd835 100644 --- a/src/Mobs/Villager.h +++ b/src/Mobs/Villager.h @@ -37,9 +37,8 @@ public: /** return true if the given blocktype are: crops, potatoes or carrots.*/ bool IsBlockFarmable(BLOCKTYPE a_BlockType); - ////////////////////////////////////////////////////////////////// // Farmer functions - /** It searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/ + /** Searches in a 11x7x11 area for crops. If it found some it will navigate to them.*/ void HandleFarmerPrepareFarmCrops(); /** Looks if the farmer has reached it's destination, and if it's still crops and the destination is closer then 2 blocks it will harvest them.*/ @@ -49,7 +48,7 @@ public: void HandleFarmerPlaceCrops(); // Get and set functions. - int GetVilType(void) const { return m_Type; } + int GetVilType(void) const { return m_Type; } Vector3i GetCropsPos(void) const { return m_CropsPos; } bool DoesHaveActionActivated(void) const { return m_VillagerAction; } diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index e6268abc7..5bb97d30e 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -36,7 +36,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) { m_IsAngry = true; } - m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face + m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face return true; } @@ -114,7 +114,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } case E_ITEM_DYE: { - if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? { SetCollarColor(15 - a_Player.GetEquippedItem().m_ItemDamage); if (!a_Player.IsGameModeCreative()) @@ -126,7 +126,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) } default: { - if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? + if (a_Player.GetName() == m_OwnerName) // Is the player the owner of the dog? { SetIsSitting(!IsSitting()); } @@ -172,7 +172,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) m_World->BroadcastEntityMetadata(*this); } - m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food + m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food // Don't move to the player if the wolf is sitting. if (!IsSitting()) diff --git a/src/Noise.cpp b/src/Noise.cpp index e7b055ead..145bcc5dd 100644 --- a/src/Noise.cpp +++ b/src/Noise.cpp @@ -9,7 +9,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Globals: void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase) @@ -90,7 +90,7 @@ void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, cons -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCubicCell2D: class cCubicCell2D @@ -239,7 +239,7 @@ void cCubicCell2D::Move(int a_NewFloorX, int a_NewFloorY) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCubicCell3D: class cCubicCell3D @@ -422,7 +422,7 @@ void cCubicCell3D::Move(int a_NewFloorX, int a_NewFloorY, int a_NewFloorZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cNoise: cNoise::cNoise(int a_Seed) : @@ -582,7 +582,7 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCubicNoise: #ifdef _DEBUG @@ -782,7 +782,7 @@ void cCubicNoise::CalcFloorFrac( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cPerlinNoise: cPerlinNoise::cPerlinNoise(void) : @@ -952,7 +952,7 @@ void cPerlinNoise::Generate3D( -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRidgedMultiNoise: cRidgedMultiNoise::cRidgedMultiNoise(void) : diff --git a/src/Noise.h b/src/Noise.h index 014e43239..48a1c73f7 100644 --- a/src/Noise.h +++ b/src/Noise.h @@ -256,7 +256,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Inline function definitions: // These need to be in the header, otherwise linker error occur in MSVC @@ -361,7 +361,7 @@ NOISE_DATATYPE cNoise::LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Global functions: extern void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase); diff --git a/src/OSSupport/CriticalSection.cpp b/src/OSSupport/CriticalSection.cpp index bda97e3a1..6d4afce55 100644 --- a/src/OSSupport/CriticalSection.cpp +++ b/src/OSSupport/CriticalSection.cpp @@ -6,7 +6,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCriticalSection: cCriticalSection::cCriticalSection() @@ -105,7 +105,7 @@ bool cCriticalSection::IsLockedByCurrentThread(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCSLock cCSLock::cCSLock(cCriticalSection * a_CS) @@ -165,7 +165,7 @@ void cCSLock::Unlock(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCSUnlock: cCSUnlock::cCSUnlock(cCSLock & a_Lock) : diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index addf8f928..ff6fb5898 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -81,7 +81,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode) m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), Mode, _SH_DENYWR); #else m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode); -#endif // _WIN32 +#endif // _WIN32 if ((m_File == NULL) && (iMode == fmReadWrite)) { @@ -94,7 +94,7 @@ bool cFile::Open(const AString & iFileName, eMode iMode) m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+", _SH_DENYWR); #else m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+"); -#endif // _WIN32 +#endif // _WIN32 } return (m_File != NULL); diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index 468de6858..60e5564e4 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -36,10 +36,10 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* } #else m_Handle = CreateSemaphore( - NULL, // security attribute - a_InitialCount, // initial count - a_MaxCount, // maximum count - 0 // name (optional) + NULL, // security attribute + a_InitialCount, // initial count + a_MaxCount, // maximum count + 0 // name (optional) ); #endif } diff --git a/src/OSSupport/Semaphore.h b/src/OSSupport/Semaphore.h index fbe8907f1..ac574e8a1 100644 --- a/src/OSSupport/Semaphore.h +++ b/src/OSSupport/Semaphore.h @@ -9,7 +9,7 @@ public: void Wait(); void Signal(); private: - void* m_Handle; // HANDLE pointer + void* m_Handle; // HANDLE pointer #ifndef _WIN32 bool m_bNamed; diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index 70fb06b40..b18d918fa 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -12,7 +12,7 @@ void cSleep::MilliSleep( unsigned int a_MilliSeconds ) { #ifdef _WIN32 - Sleep(a_MilliSeconds); // Don't tick too much + Sleep(a_MilliSeconds); // Don't tick too much #else usleep(a_MilliSeconds*1000); #endif diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp index ca8b8438d..f436318a5 100644 --- a/src/OSSupport/SocketThreads.cpp +++ b/src/OSSupport/SocketThreads.cpp @@ -13,7 +13,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSocketThreads: cSocketThreads::cSocketThreads(void) diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 535784613..674e37757 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -91,12 +91,12 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; - HANDLE hThread = CreateThread( 0 // security - ,0 // stack size - , (LPTHREAD_START_ROUTINE) MyThread // function name - ,this // parameters - ,0 // flags - ,&ThreadID ); // thread id + HANDLE hThread = CreateThread( 0 // security + ,0 // stack size + , (LPTHREAD_START_ROUTINE) MyThread // function name + ,this // parameters + ,0 // flags + ,&ThreadID ); // thread id CloseHandle( hThread ); #ifdef _MSC_VER diff --git a/src/PolarSSL++/Sha1Checksum.cpp b/src/PolarSSL++/Sha1Checksum.cpp index a1ee9d7b9..e69ef236f 100644 --- a/src/PolarSSL++/Sha1Checksum.cpp +++ b/src/PolarSSL++/Sha1Checksum.cpp @@ -50,7 +50,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSha1Checksum: cSha1Checksum::cSha1Checksum(void) : diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index dc35a6653..00eeadd10 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -132,7 +132,7 @@ public: protected: cClientHandle * m_Client; - cCriticalSection m_CSPacket; //< Each SendXYZ() function must acquire this CS in order to send the whole packet at once + cCriticalSection m_CSPacket; // Each SendXYZ() function must acquire this CS in order to send the whole packet at once /// A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it virtual void SendData(const char * a_Data, size_t a_Size) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 28fdcf23a..325218d88 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -473,7 +473,7 @@ void cProtocol125::SendEntityVelocity(const cEntity & a_Entity) cCSLock Lock(m_CSPacket); WriteByte(PACKET_ENTITY_VELOCITY); WriteInt (a_Entity.GetUniqueID()); - WriteShort((short) (a_Entity.GetSpeedX() * 400)); //400 = 8000 / 20 + WriteShort((short) (a_Entity.GetSpeedX() * 400)); // 400 = 8000 / 20 WriteShort((short) (a_Entity.GetSpeedY() * 400)); WriteShort((short) (a_Entity.GetSpeedZ() * 400)); Flush(); @@ -1426,11 +1426,11 @@ int cProtocol125::ParseEntityAction(void) switch (ActionID) { - case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch - case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch - case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed - case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting - case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting + case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch + case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch + case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed + case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting + case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting } return PARSE_OK; @@ -1444,7 +1444,7 @@ int cProtocol125::ParseHandshake(void) { HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username); - AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565" + AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565" if (UserData.empty()) { m_Client->Kick("Did not receive username"); @@ -1456,7 +1456,7 @@ int cProtocol125::ParseHandshake(void) if (!m_Client->HandleHandshake( m_Username )) { - return PARSE_OK; // Player is not allowed into the server + return PARSE_OK; // Player is not allowed into the server } SendHandshake(cRoot::Get()->GetServer()->GetServerID()); @@ -1918,20 +1918,20 @@ void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity) // No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4 ); WriteByte(0x52); - WriteInt(1); // Shaking direction, doesn't seem to affect anything + WriteInt(1); // Shaking direction, doesn't seem to affect anything WriteByte(0x73); - WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer + WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpFurnace) { WriteByte(0x10); - WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled? + WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled? } } else if ((a_Entity.IsProjectile() && ((cProjectileEntity &)a_Entity).GetProjectileKind() == cProjectileEntity::pkArrow)) { WriteByte(0x10); - WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow? + WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow? } } @@ -1946,43 +1946,43 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtCreeper: { WriteByte(0x10); - WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up? + WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up? WriteByte(0x11); - WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged? + WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged? break; } case cMonster::mtBat: { WriteByte(0x10); - WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down? + WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down? break; } case cMonster::mtPig: { WriteByte(0x10); - WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled? + WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled? break; } case cMonster::mtVillager: { WriteByte(0x50); - WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE? + WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE? break; } case cMonster::mtZombie: { WriteByte(0xC); - WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Babby zombie? + WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie? WriteByte(0xD); - WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie? + WriteByte(((const cZombie &)a_Mob).IsVillagerZombie() ? 1 : 0); // Converted zombie? WriteByte(0xE); - WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager? + WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager? break; } case cMonster::mtGhast: { WriteByte(0x10); - WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to eject un flamé-bol? :P + WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball? break; } case cMonster::mtWolf: @@ -2004,9 +2004,9 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(WolfStatus); WriteByte(0x72); - WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way) + WriteFloat((float)(a_Mob.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way) WriteByte(0x13); - WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode? + WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode? break; } case cMonster::mtSheep: @@ -2028,30 +2028,30 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtEnderman: { WriteByte(0x10); - WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house + WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house WriteByte(0x11); - WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house + WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedMeta())); // Meta of block that he stole from your house WriteByte(0x12); - WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face? + WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face? break; } case cMonster::mtSkeleton: { WriteByte(0xD); - WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not + WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not break; } case cMonster::mtWitch: { WriteByte(0x15); - WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything + WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything break; } case cMonster::mtWither: { - WriteByte(0x54); // Int at index 20 + WriteByte(0x54); // Int at index 20 WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks()); - WriteByte(0x66); // Float at index 6 + WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; } @@ -2061,11 +2061,11 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteByte(0x10); if (a_Mob.GetMobType() == cMonster::mtSlime) { - WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME + WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME } else { - WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME + WriteByte((Byte)((const cMagmaCube &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME } break; } @@ -2086,7 +2086,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) } if (((const cHorse &)a_Mob).IsBaby()) { - Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer + Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer } if (((const cHorse &)a_Mob).IsEating()) { @@ -2104,16 +2104,16 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) WriteInt(Flags); WriteByte(0x13); - WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.) + WriteByte((Byte)((const cHorse &)a_Mob).GetHorseType()); // Type of horse (donkey, chestnut, etc.) WriteByte(0x54); int Appearance = 0; - Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF - Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256 + Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF + Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256 WriteInt(Appearance); WriteByte(0x56); - WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour + WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour break; } default: diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 86a49f3f6..c0696d206 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -76,8 +76,8 @@ public: 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; - 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 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, 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; diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 7a8c2221e..a92ae83da 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -71,7 +71,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol132: cProtocol132::cProtocol132(cClientHandle * a_Client) : @@ -476,7 +476,7 @@ int cProtocol132::ParseHandshake(void) if (!m_Client->HandleHandshake( m_Username )) { - return PARSE_OK; // Player is not allowed into the server + return PARSE_OK; // Player is not allowed into the server } // Send a 0xfd Encryption Key Request http://wiki.vg/Protocol#0xFD diff --git a/src/Protocol/Protocol14x.cpp b/src/Protocol/Protocol14x.cpp index f60e756fd..8b177ea48 100644 --- a/src/Protocol/Protocol14x.cpp +++ b/src/Protocol/Protocol14x.cpp @@ -66,7 +66,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol142: cProtocol142::cProtocol142(cClientHandle * a_Client) : @@ -144,7 +144,7 @@ void cProtocol142::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol146: cProtocol146::cProtocol146(cClientHandle * a_Client) : diff --git a/src/Protocol/Protocol15x.cpp b/src/Protocol/Protocol15x.cpp index 264a596b9..2b1f01b08 100644 --- a/src/Protocol/Protocol15x.cpp +++ b/src/Protocol/Protocol15x.cpp @@ -47,7 +47,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol150: cProtocol150::cProtocol150(cClientHandle * a_Client) : diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index eba795f61..a163922c5 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -55,7 +55,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol161: cProtocol161::cProtocol161(cClientHandle * a_Client) : @@ -202,11 +202,11 @@ int cProtocol161::ParseEntityAction(void) switch (ActionID) { - case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch - case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch - case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed - case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting - case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting + case 1: m_Client->HandleEntityCrouch(EntityID, true); break; // Crouch + case 2: m_Client->HandleEntityCrouch(EntityID, false); break; // Uncrouch + case 3: m_Client->HandleEntityLeaveBed(EntityID); break; // Leave Bed + case 4: m_Client->HandleEntitySprinting(EntityID, true); break; // Start sprinting + case 5: m_Client->HandleEntitySprinting(EntityID, false); break; // Stop sprinting } return PARSE_OK; @@ -282,7 +282,7 @@ int cProtocol161::ParsePacket(unsigned char a_PacketType) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol162: cProtocol162::cProtocol162(cClientHandle * a_Client) : diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 50c2014c6..36d1f4af4 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -81,7 +81,7 @@ extern bool g_ShouldLogCommIn, g_ShouldLogCommOut; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol172: cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : @@ -651,7 +651,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World) cServer * Server = cRoot::Get()->GetServer(); cPacketizer Pkt(*this, 0x01); // Join Game packet Pkt.WriteInt(a_Player.GetUniqueID()); - Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 + Pkt.WriteByte((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 Pkt.WriteChar((char)a_World.GetDimension()); Pkt.WriteByte(2); // TODO: Difficulty (set to Normal) Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60)); @@ -807,7 +807,7 @@ void cProtocol172::SendPlayerAbilities(void) if (Player->IsGameModeCreative()) { Flags |= 0x01; - Flags |= 0x08; // Godmode, used for creative + Flags |= 0x08; // Godmode, used for creative } if (Player->IsFlying()) { @@ -1130,7 +1130,7 @@ void cProtocol172::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) Pkt.WriteFPInt(a_FallingBlock.GetPosZ()); Pkt.WriteByteAngle(a_FallingBlock.GetYaw()); Pkt.WriteByteAngle(a_FallingBlock.GetPitch()); - Pkt.WriteInt(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 16)); // Or 0x10 + Pkt.WriteInt(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 16)); // Or 0x10 Pkt.WriteShort((short)(a_FallingBlock.GetSpeedX() * 400)); Pkt.WriteShort((short)(a_FallingBlock.GetSpeedY() * 400)); Pkt.WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400)); @@ -1219,7 +1219,7 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager) ASSERT(m_State == 3); // In game mode? cPacketizer Pkt(*this, 0x37); - Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only + Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only for (size_t i = 0; i < (size_t)statCount; ++i) { @@ -1326,10 +1326,10 @@ void cProtocol172::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity) Byte Action = 0; switch (a_BlockEntity.GetBlockType()) { - case E_BLOCK_MOB_SPAWNER: Action = 1; break; // Update mob spawner spinny mob thing - case E_BLOCK_COMMAND_BLOCK: Action = 2; break; // Update command block text - case E_BLOCK_HEAD: Action = 4; break; // Update Mobhead entity - case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot + case E_BLOCK_MOB_SPAWNER: Action = 1; break; // Update mob spawner spinny mob thing + case E_BLOCK_COMMAND_BLOCK: Action = 2; break; // Update command block text + case E_BLOCK_HEAD: Action = 4; break; // Update Mobhead entity + case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot default: ASSERT(!"Unhandled or unimplemented BlockEntity update request!"); break; } Pkt.WriteByte(Action); @@ -1656,7 +1656,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) case 0x0c: HandlePacketSteerVehicle (a_ByteBuffer); return true; case 0x0d: HandlePacketWindowClose (a_ByteBuffer); return true; case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true; - case 0x0f: // Confirm transaction - not used in MCS + case 0x0f: // Confirm transaction - not used in MCS case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true; case 0x11: HandlePacketEnchantItem (a_ByteBuffer); return true; case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true; @@ -1950,11 +1950,11 @@ void cProtocol172::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) switch (Action) { - case 1: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch - case 2: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch - case 3: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed - case 4: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting - case 5: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting + case 1: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch + case 2: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch + case 3: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed + case 4: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting + case 5: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting } } @@ -2311,7 +2311,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) { case TAG_List: { - if ((TagName == "ench") || (TagName == "StoredEnchantments")) // Enchantments tags + if ((TagName == "ench") || (TagName == "StoredEnchantments")) // Enchantments tags { EnchantmentSerializer::ParseFromNBT(a_Item.m_Enchantments, NBT, tag); } @@ -2319,21 +2319,21 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) } case TAG_Compound: { - if (TagName == "display") // Custom name and lore tag + if (TagName == "display") // Custom name and lore tag { for (int displaytag = NBT.GetFirstChild(tag); displaytag >= 0; displaytag = NBT.GetNextSibling(displaytag)) { - if ((NBT.GetType(displaytag) == TAG_String) && (NBT.GetName(displaytag) == "Name")) // Custon name tag + if ((NBT.GetType(displaytag) == TAG_String) && (NBT.GetName(displaytag) == "Name")) // Custon name tag { a_Item.m_CustomName = NBT.GetString(displaytag); } - else if ((NBT.GetType(displaytag) == TAG_List) && (NBT.GetName(displaytag) == "Lore")) // Lore tag + else if ((NBT.GetType(displaytag) == TAG_List) && (NBT.GetName(displaytag) == "Lore")) // Lore tag { AString Lore; - for (int loretag = NBT.GetFirstChild(displaytag); loretag >= 0; loretag = NBT.GetNextSibling(loretag)) // Loop through array of strings + 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 grave accent/backtick, 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; @@ -2463,7 +2463,7 @@ void cProtocol172::AddChatPartStyle(Json::Value & a_Value, const AString & a_Par -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol172::cPacketizer: cProtocol172::cPacketizer::~cPacketizer() @@ -2585,7 +2585,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt { cCommandBlockEntity & CommandBlockEntity = (cCommandBlockEntity &)a_BlockEntity; - Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this + Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this Writer.AddInt("SuccessCount", CommandBlockEntity.GetResult()); Writer.AddInt("x", CommandBlockEntity.GetPosX()); Writer.AddInt("y", CommandBlockEntity.GetPosY()); @@ -2595,7 +2595,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt // For a command block, this would be the 'name' prepended to anything it outputs into global chat // MCS doesn't have this, so just leave it @ '@'. (geddit?) Writer.AddString("CustomName", "@"); - Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though if (!CommandBlockEntity.GetLastOutput().empty()) { @@ -2616,7 +2616,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF); Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF); Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str()); - Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though break; } case E_BLOCK_FLOWER_POT: @@ -2628,7 +2628,7 @@ void cProtocol172::cPacketizer::WriteBlockEntity(const cBlockEntity & a_BlockEnt Writer.AddInt("z", FlowerPotEntity.GetPosZ()); Writer.AddInt("Item", (Int32) FlowerPotEntity.GetItem().m_ItemType); Writer.AddInt("Data", (Int32) FlowerPotEntity.GetItem().m_ItemDamage); - Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though + Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though break; } default: break; @@ -2713,9 +2713,9 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity) */ WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); WriteByte(0x52); - WriteInt(1); // Shaking direction, doesn't seem to affect anything + WriteInt(1); // Shaking direction, doesn't seem to affect anything WriteByte(0x73); - WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer + WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpNone) { @@ -2903,9 +2903,9 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob) case cMonster::mtWither: { - WriteByte(0x54); // Int at index 20 + WriteByte(0x54); // Int at index 20 WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks()); - WriteByte(0x66); // Float at index 6 + WriteByte(0x66); // Float at index 6 WriteFloat((float)(a_Mob.GetHealth())); break; } @@ -2985,7 +2985,7 @@ void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity) return; } - //const cMonster & Mob = (const cMonster &)a_Entity; + // const cMonster & Mob = (const cMonster &)a_Entity; // TODO: Send properties and modifiers based on the mob type @@ -2996,7 +2996,7 @@ void cProtocol172::cPacketizer::WriteEntityProperties(const cEntity & a_Entity) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cProtocol176: cProtocol176::cProtocol176(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index e5ec3ece2..25c60a72e 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -139,8 +139,8 @@ public: virtual void SendData(const char * a_Data, size_t a_Size) override; protected: - cProtocol * m_Protocol; //< The recognized protocol - cByteBuffer m_Buffer; //< Buffer for the incoming data until we recognize the protocol + cProtocol * m_Protocol; ///< The recognized protocol + cByteBuffer m_Buffer; ///< Buffer for the incoming data until we recognize the protocol /// Tries to recognize protocol based on m_Buffer contents; returns true if recognized bool TryRecognizeProtocol(void); diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index c511968be..28cb1e03b 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -38,7 +38,7 @@ enum -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRCONCommandOutput: class cRCONCommandOutput : @@ -73,7 +73,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRCONServer: cRCONServer::cRCONServer(cServer & a_Server) : @@ -154,7 +154,7 @@ void cRCONServer::OnConnectionAccepted(cSocket & a_Socket) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cRCONServer::cConnection: cRCONServer::cConnection::cConnection(cRCONServer & a_RCONServer, cSocket & a_Socket) : diff --git a/src/Server.cpp b/src/Server.cpp index 81ecd38b2..bc9644804 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -60,7 +60,7 @@ typedef std::list< cClientHandle* > ClientList; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cServer::cTickThread: cServer::cTickThread::cTickThread(cServer & a_Server) : @@ -101,7 +101,7 @@ void cServer::cTickThread::Execute(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cServer: cServer::cServer(void) : @@ -673,7 +673,7 @@ void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const ASt -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cServer::cNotifyWriteThread: cServer::cNotifyWriteThread::cNotifyWriteThread(void) : diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index 5ff736231..884069b21 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -14,7 +14,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDelayedFluidSimulatorChunkData::cSlot bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_RelZ) @@ -40,7 +40,7 @@ bool cDelayedFluidSimulatorChunkData::cSlot::Add(int a_RelX, int a_RelY, int a_R -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDelayedFluidSimulatorChunkData: cDelayedFluidSimulatorChunkData::cDelayedFluidSimulatorChunkData(int a_TickDelay) : @@ -62,7 +62,7 @@ cDelayedFluidSimulatorChunkData::~cDelayedFluidSimulatorChunkData() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDelayedFluidSimulator: cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay) : diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 311f8b4c4..1ad4f2654 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -63,7 +63,7 @@ static const struct -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFireSimulator: cFireSimulator::cFireSimulator(cWorld & a_World, cIniFile & a_IniFile) : diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index f64955cb2..99aa11728 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -125,31 +125,31 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a return NONE; } BLOCKTYPE BlockID = m_World.GetBlock(a_X, a_Y, a_Z); - if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D + if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D { return NONE; } /* Disabled because of causing problems and being useless atm - char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); //If there is nothing or fluid below it -> dominating flow is down :D + char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); // If there is nothing or fluid below it -> dominating flow is down :D if (BlockBelow == E_BLOCK_AIR || IsAllowedBlock(BlockBelow)) return Y_MINUS; */ - NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); //Current Block Meta so only lower points will be counted - int X = 0, Z = 0; //Lowest Pos will be stored here + NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted + int X = 0, Z = 0; // Lowest Pos will be stored here - if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) //check for upper block to flow because this also affects the flowing direction + if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) // check for upper block to flow because this also affects the flowing direction { return GetFlowingDirection(a_X, a_Y + 1, a_Z, false); } std::vector< Vector3i * > Points; - Points.reserve(4); //Already allocate 4 places :D + Points.reserve(4); // Already allocate 4 places :D - //add blocks around the checking pos + // add blocks around the checking pos Points.push_back(new Vector3i(a_X - 1, a_Y, a_Z)); Points.push_back(new Vector3i(a_X + 1, a_Y, a_Z)); Points.push_back(new Vector3i(a_X, a_Y, a_Z + 1)); @@ -172,7 +172,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a } else if(BlockID == E_BLOCK_AIR) { - LowestPoint = 9; //This always dominates + LowestPoint = 9; // This always dominates X = Pos->x; Z = Pos->z; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 55c5cbd09..0d4815c00 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -190,16 +190,16 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, cRedstoneSimulatorChunkData * RedstoneSimulatorChunkData = a_Chunk->GetRedstoneSimulatorData(); for (cRedstoneSimulatorChunkData::iterator itr = RedstoneSimulatorChunkData->begin(); itr != RedstoneSimulatorChunkData->end(); ++itr) { - if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) // We are at an entry matching the current (changed) block + if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) // We are at an entry matching the current (changed) block { if (!IsAllowedBlock(Block)) { - itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list + itr->DataTwo = true; // The new blocktype is not redstone; it must be queued to be removed from this list } else { itr->DataTwo = false; - itr->Data = Block; // Update block information + itr->Data = Block; // Update block information } return; } @@ -378,7 +378,7 @@ void cIncrementalRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_Blo void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, BLOCKTYPE a_MyState) { - static const struct // Define which directions the torch can power + static const struct // Define which directions the torch can power { int x, y, z; } gCrossCoords[] = @@ -394,7 +394,7 @@ 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 + 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()) @@ -417,11 +417,11 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R { continue; } - if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last) + if (i + 1 < ARRAYCOUNT(gCrossCoords)) // Sides of torch, not top (top is last) { if ( - 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 + 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 ) { SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ); @@ -436,11 +436,11 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R } } - if (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath + if (m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) != 0x5) // Is torch standing on ground? If NOT (i.e. on wall), power block beneath { BLOCKTYPE Type = m_Chunk->GetBlock(a_RelBlockX, a_RelBlockY - 1, a_RelBlockZ); - if (IsMechanism(Type)) // 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); } @@ -450,7 +450,7 @@ 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 + 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()) @@ -461,7 +461,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R // See if off state torch can be turned on again if (AreCoordsDirectlyPowered(X, Y, Z, Neighbour)) { - return; // Something matches, torch still powered + return; // Something matches, torch still powered } // Block torch on not powered, can be turned on again! @@ -476,7 +476,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R void cIncrementalRedstoneSimulator::HandleRedstoneBlock(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); - SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Set self as powered + SetBlockPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Set self as powered } @@ -557,7 +557,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneButton(int a_RelBlockX, int a_ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ) { - static const struct // Define which directions the wire can receive power from + static const struct // Define which directions the wire can receive power from { int x, y, z; } gCrossCoords[] = @@ -576,7 +576,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re { 0,-1, -1}, /* Wires one lower, surrounding self stop */ } ; - static const struct // Define which directions the wire will check for repeater prescence + static const struct // Define which directions the wire will check for repeater prescence { int x, y, z; } gSideCoords[] = @@ -608,9 +608,9 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re MyPower--; - for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through all directions to transfer or receive power + for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through all directions to transfer or receive power { - if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above... + if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above... { BLOCKTYPE Type = 0; if (a_RelBlockY + 1 >= cChunkDef::Height) @@ -621,12 +621,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re { continue; } - if (cBlockInfo::IsSolid(Type)) // If there is something solid above us (wire cut off)... + if (cBlockInfo::IsSolid(Type)) // If there is something solid above us (wire cut off)... { - continue; // We don't receive power from that wire + continue; // We don't receive power from that wire } } - else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us + else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us { BLOCKTYPE Type = 0; if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY, a_RelBlockZ + gCrossCoords[i].z, Type)) @@ -650,7 +650,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_RelBlockX, int a_Re } } - for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them + for (size_t i = 0; i < ARRAYCOUNT(gSideCoords); i++) // Look for repeaters immediately surrounding self and try to power them { BLOCKTYPE Type = 0; if (!m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + gSideCoords[i].x, a_RelBlockY + gSideCoords[i].y, a_RelBlockZ + gSideCoords[i].z, Type)) @@ -740,14 +740,14 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: + if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); - if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. + if (IsSelfPowered && !IsOn) // Queue a power change if powered, but not on and not locked. { QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, true); } - else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. + else if (!IsSelfPowered && IsOn) // Queue a power change if unpowered, on, and not locked. { QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false); } @@ -758,7 +758,7 @@ 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? + 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; @@ -768,12 +768,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() m_Chunk->GetBlockTypeMeta(RelBlockX, RelBlockY, RelBlockZ, Block, Meta); if (itr->ShouldPowerOn) { - if (Block != E_BLOCK_REDSTONE_REPEATER_ON) // 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 + switch (Meta & 0x3) // We only want the direction (bottom) bits { case 0x0: { @@ -825,7 +825,7 @@ void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlock int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) + if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness) { cBlockPistonHandler::ExtendPiston(BlockX, a_RelBlockY, BlockZ, &m_World); } @@ -1280,7 +1280,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R 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 + return true; // Break out, we only need to know for plates that at least one entity is on top } return false; } @@ -1343,7 +1343,7 @@ void cIncrementalRedstoneSimulator::HandleTripwireHook(int a_RelBlockX, int a_Re 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 + for (int i = 0; i < 40; ++i) // Tripwires can be connected up to 40 blocks { BLOCKTYPE Type; NIBBLETYPE Meta; @@ -1469,7 +1469,7 @@ void cIncrementalRedstoneSimulator::HandleTripwire(int a_RelBlockX, int a_RelBlo if (bbEntity.DoesIntersect(bbWire)) { m_FoundEntity = true; - return true; // One entity is sufficient to trigger the wire + return true; // One entity is sufficient to trigger the wire } return false; } @@ -1511,7 +1511,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, in int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - for (PoweredBlocksList::const_iterator itr = a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->begin(); itr != a_Chunk->GetRedstoneSimulatorPoweredBlocksList()->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))) { @@ -1530,7 +1530,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_RelBlockX, int int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX; int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ; - for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list + for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list { if (itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { @@ -1608,7 +1608,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_Rel } } } - return false; // Couldn't find power source behind repeater + return false; // Couldn't find power source behind repeater } @@ -1617,7 +1617,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_Rel bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) { - switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata + switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata { // If the repeater is looking up or down (If parallel to the Z axis) case 0x0: @@ -1625,17 +1625,17 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB { // Check if eastern(right) neighbor is a powered on repeater who is facing us BLOCKTYPE Block = 0; - if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater? + if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater? { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3; - if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked + if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked } // Check if western(left) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3; - if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked + if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked } break; @@ -1650,21 +1650,21 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3; - if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked + if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked } // Check if northern(up) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3; - if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked + if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked } break; } } - return false; // None of the checks succeeded, I am not a locked repeater + return false; // None of the checks succeeded, I am not a locked repeater } @@ -1705,7 +1705,7 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true); } - return false; // Source was in front of the piston's front face + return false; // Source was in front of the piston's front face } @@ -1717,16 +1717,16 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc 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 + for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr) // Check powered list { if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; } - 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) + 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 + for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list { if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { @@ -1743,7 +1743,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc a_PowerLevel = std::max(itr->a_PowerLevel, a_PowerLevel); } - return (a_PowerLevel != 0); // Answer the inital question: is the wire powered? + return (a_PowerLevel != 0); // Answer the inital question: is the wire powered? } @@ -1756,17 +1756,17 @@ bool cIncrementalRedstoneSimulator::AreCoordsSimulated(int a_RelBlockX, int a_Re { if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { - if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current? + if (itr->WasLastStatePowered != IsCurrentStatePowered) // Was the last power state different to the current? { - return false; // It was, coordinates are no longer simulated + return false; // It was, coordinates are no longer simulated } else { - return true; // It wasn't, don't resimulate block, and allow players to toggle + return true; // It wasn't, don't resimulate block, and allow players to toggle } } } - return false; // Block wasn't even in the list, not simulated + return false; // Block wasn't even in the list, not simulated } @@ -1870,7 +1870,7 @@ void cIncrementalRedstoneSimulator::SetDirectionLinkedPowered(int a_RelBlockX, i } default: { - ASSERT(!"Unhandled face direction when attempting to set blocks as linked powered!"); // Zombies, that wasn't supposed to happen... + ASSERT(!"Unhandled face direction when attempting to set blocks as linked powered!"); // Zombies, that wasn't supposed to happen... break; } } @@ -1895,7 +1895,7 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_RelBlockX, int a_R { 0, -1, 0 } }; - for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions + for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) // Loop through struct to power all directions { SetBlockPowered(a_RelBlockX + gCrossCoords[i].x, a_RelBlockY + gCrossCoords[i].y, a_RelBlockZ + gCrossCoords[i].z, a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_PowerLevel); } @@ -1912,13 +1912,13 @@ 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->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values + 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 + 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 ( @@ -1950,7 +1950,7 @@ void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBl { if (Meta < a_PowerLevel) { - m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it + m_PoweredBlocks->erase(itr); // Powering source with higher power level, allow it break; } else @@ -2068,13 +2068,13 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in { if (itr->a_RelBlockPos.Equals(Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ))) { - if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry + if (ShouldPowerOn == itr->ShouldPowerOn) // We are queued already for the same thing, don't replace entry { return false; } // Already in here (normal to allow repeater to continue on powering and updating blocks in front) - just update info and quit - itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description + itr->a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; // See below for description itr->a_ElapsedTicks = 0; itr->ShouldPowerOn = ShouldPowerOn; return false; @@ -2086,7 +2086,7 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) - // * 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility + // Multiply by 2 because in MCS, 1 redstone tick = 1 world tick, but in Vanilla, 1 redstone tick = 2 world ticks, and we need to maintain compatibility RC.a_DelayTicks = (((a_Meta & 0xC) >> 0x2) + 1) * 2; RC.a_ElapsedTicks = 0; @@ -2101,7 +2101,7 @@ 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_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid { if ((a_Chunk == NULL) || !a_Chunk->IsValid()) { diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 1faf4187b..878f88b71 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -38,33 +38,33 @@ private: #define MAX_POWER_LEVEL 15 - struct sPoweredBlocks // Define structure of the directly powered blocks list + struct sPoweredBlocks // Define structure of the directly powered blocks list { - Vector3i a_BlockPos; // Position of powered block - Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos + Vector3i a_BlockPos; // Position of powered block + Vector3i a_SourcePos; // Position of source powering the block at a_BlockPos unsigned char a_PowerLevel; }; - struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side) + struct sLinkedPoweredBlocks // Define structure of the indirectly powered blocks list (i.e. repeaters powering through a block to the block at the other side) { Vector3i a_BlockPos; - Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination + Vector3i a_MiddlePos; // Position of block that is betwixt a source and the destination Vector3i a_SourcePos; unsigned char a_PowerLevel; }; - struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player) + struct sSimulatedPlayerToggleableList // Define structure of the list containing simulate-on-update blocks (such as trapdoors that respond once to a block update, and can be toggled by a player) { Vector3i a_RelBlockPos; - bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate + bool WasLastStatePowered; // Was the last state powered or not? Determines whether a source update has happened and if I should resimulate }; - struct sRepeatersDelayList // Define structure of list containing repeaters' delay states + struct sRepeatersDelayList // Define structure of list containing repeaters' delay states { Vector3i a_RelBlockPos; - unsigned char a_DelayTicks; // For how many ticks should the repeater delay - unsigned char a_ElapsedTicks; // How much of the previous has been elapsed? - bool ShouldPowerOn; // What happens when the delay time is fulfilled? + unsigned char a_DelayTicks; // For how many ticks should the repeater delay + unsigned char a_ElapsedTicks; // How much of the previous has been elapsed? + bool ShouldPowerOn; // What happens when the delay time is fulfilled? }; public: @@ -302,7 +302,7 @@ private: 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 + 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) || diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h index fe3949198..e5338ad44 100644 --- a/src/Simulator/NoopRedstoneSimulator.h +++ b/src/Simulator/NoopRedstoneSimulator.h @@ -18,7 +18,7 @@ public: { } - //~cRedstoneNoopSimulator(); + // ~cRedstoneNoopSimulator(); virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 9429157a9..f60ed1248 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -339,9 +339,9 @@ AString & RawBEToUTF8(const char * a_RawData, size_t a_NumShorts, AString & a_UT // UTF-8 conversion code adapted from: // http://stackoverflow.com/questions/2867123/convert-utf-16-to-utf-8-under-windows-and-linux-in-c -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Begin of Unicode, Inc.'s code / information -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// /* Notice from the original file: @@ -519,9 +519,9 @@ are equivalent to the following loop: --------------------------------------------------------------------- */ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // End of Unicode, Inc.'s code / information -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Tracer.cpp b/src/Tracer.cpp index d788d9e26..54b4716e3 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -273,36 +273,50 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl // 2 = the segment lies in the plane int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ) { - Vector3f u = a_End - a_Origin;//a_Ray.P1 - S.P0; - Vector3f w = a_Origin - a_PlanePos;//S.P0 - Pn.V0; + Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0; + Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0; - float D = a_PlaneNormal.Dot( u );//dot(Pn.n, u); - float N = -(a_PlaneNormal.Dot( w ) );//-dot(a_Plane.n, w); + float D = a_PlaneNormal.Dot( u ); // dot(Pn.n, u); + float N = -(a_PlaneNormal.Dot( w ) ); // -dot(a_Plane.n, w); const float EPSILON = 0.0001f; - if (fabs(D) < EPSILON) { // segment is parallel to plane - if (N == 0) // segment lies in plane + if (fabs(D) < EPSILON) + { + // segment is parallel to plane + if (N == 0) + { + // segment lies in plane return 2; - return 0; // no intersection + } + return 0; // no intersection } + // they are not parallel // compute intersect param float sI = N / D; if (sI < 0 || sI > 1) - return 0; // no intersection + { + return 0; // no intersection + } - // Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u );// S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } + + + + int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos) { Vector3i SmallBlockPos = a_BlockPos; char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) + { return 0; + } Vector3f BlockPos; BlockPos = Vector3f(SmallBlockPos); diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index e220960ff..0a9502491 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -20,7 +20,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotArea: cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) : @@ -108,9 +108,9 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA { case caRightClick: { - if (DraggingItem.m_ItemType <= 0) // Empty-handed? + if (DraggingItem.m_ItemType <= 0) // Empty-handed? { - DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc. + DraggingItem = Slot.CopyOne(); // Obtain copy of slot to preserve lore, enchantments, etc. DraggingItem.m_ItemCount = (char)(((float)Slot.m_ItemCount) / 2.f + 0.5f); Slot.m_ItemCount -= DraggingItem.m_ItemCount; @@ -128,7 +128,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA { char OldSlotCount = Slot.m_ItemCount; - Slot = DraggingItem.CopyOne(); // See above + Slot = DraggingItem.CopyOne(); // See above OldSlotCount++; Slot.m_ItemCount = OldSlotCount; @@ -409,7 +409,7 @@ bool cSlotArea::CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaChest: cSlotAreaChest::cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow) : @@ -441,7 +441,7 @@ void cSlotAreaChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaDoubleChest: cSlotAreaDoubleChest::cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow) : @@ -488,7 +488,7 @@ void cSlotAreaDoubleChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cIte -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaCrafting: cSlotAreaCrafting::cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow) : @@ -764,7 +764,7 @@ void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Play -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaAnvil: cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) : @@ -1191,7 +1191,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnchanting: cSlotAreaEnchanting::cSlotAreaEnchanting(cEnchantingWindow & a_ParentWindow) : @@ -1496,7 +1496,7 @@ int cSlotAreaEnchanting::GetBookshelvesCount(cWorld * a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnderChest: cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow) : @@ -1527,7 +1527,7 @@ void cSlotAreaEnderChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaFurnace: cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) : @@ -1763,7 +1763,7 @@ void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Playe -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaInventoryBase: cSlotAreaInventoryBase::cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow) : @@ -1819,7 +1819,7 @@ void cSlotAreaInventoryBase::SetSlot(int a_SlotNum, cPlayer & a_Player, const cI -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaArmor: void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) @@ -1948,7 +1948,7 @@ bool cSlotAreaArmor::CanPlaceInSlot(int a_SlotNum, const cItem & a_Item) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaItemGrid: cSlotAreaItemGrid::cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow) : @@ -1999,7 +1999,7 @@ void cSlotAreaItemGrid::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSlotAreaTemporary: cSlotAreaTemporary::cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow) : @@ -2104,7 +2104,7 @@ void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End) double vX = 0, vY = 0, vZ = 0; EulerToVector(-a_Player.GetYaw(), a_Player.GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created + a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 19db01b7a..b550068b1 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -763,7 +763,7 @@ void cWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cInventoryWindow: cInventoryWindow::cInventoryWindow(cPlayer & a_Player) : @@ -780,7 +780,7 @@ cInventoryWindow::cInventoryWindow(cPlayer & a_Player) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cCraftingWindow: cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : @@ -795,7 +795,7 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cAnvilWindow: cAnvilWindow::cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : @@ -840,7 +840,7 @@ void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEnchantingWindow: cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : @@ -901,7 +901,7 @@ void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cChestWindow: cChestWindow::cChestWindow(cChestEntity * a_Chest) : @@ -1011,7 +1011,7 @@ cChestWindow::~cChestWindow() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cDropSpenserWindow: cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) : @@ -1027,7 +1027,7 @@ cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cEnderChestWindow: cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) : @@ -1065,7 +1065,7 @@ cEnderChestWindow::~cEnderChestWindow() -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cHopperWindow: cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper) : @@ -1081,7 +1081,7 @@ cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEn -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFurnaceWindow: cFurnaceWindow::cFurnaceWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceEntity * a_Furnace) : diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index b3eab5659..be72f2d5a 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -531,7 +531,7 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWebAdmin::cWebadminRequestData void cWebAdmin::cWebadminRequestData::OnBody(const char * a_Data, size_t a_Size) diff --git a/src/World.cpp b/src/World.cpp index 7f30f9b39..186842b20 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -70,7 +70,7 @@ const int TIME_SPAWN_DIVISOR = 148; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorldLoadProgress: /// A simple thread that displays the progress of world loading / saving in cWorld::InitializeSpawn() @@ -122,7 +122,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorldLightingProgress: /// A simple thread that displays the progress of world lighting in cWorld::InitializeSpawn() @@ -172,7 +172,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cLock: cWorld::cLock::cLock(cWorld & a_World) : @@ -184,7 +184,7 @@ cWorld::cLock::cLock(cWorld & a_World) : -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTickThread: cWorld::cTickThread::cTickThread(cWorld & a_World) : @@ -226,7 +226,7 @@ void cWorld::cTickThread::Execute(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld: cWorld::cWorld(const AString & a_WorldName) : @@ -2914,7 +2914,7 @@ void cWorld::TickQueuedBlocks(void) { // TODO: Handle the case when the chunk is already unloaded m_ChunkMap->TickBlock(Block->X, Block->Y, Block->Z); - delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick + delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick } else { @@ -3200,7 +3200,7 @@ void cWorld::AddQueuedPlayers(void) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSaveAllChunks: void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) @@ -3212,7 +3212,7 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskUnloadUnusedChunks void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World) @@ -3224,7 +3224,7 @@ void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cTaskSendBlockTo cWorld::cTaskSendBlockToAllPlayers::cTaskSendBlockToAllPlayers(std::vector & a_SendQueue) : @@ -3267,7 +3267,7 @@ void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorld::cChunkGeneratorCallbacks: cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) : diff --git a/src/World.h b/src/World.h index 725e1eb71..f0e8d5cf3 100644 --- a/src/World.h +++ b/src/World.h @@ -870,7 +870,7 @@ private: bool m_VillagersShouldHarvestCrops; std::vector m_BlockTickQueue; - std::vector m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue + std::vector m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue cSimulatorManager * m_SimulatorManager; cSandSimulator * m_SandSimulator; diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index a047d67c7..8e7247aab 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -25,7 +25,7 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cParsedNBT: #define NEEDBYTES(N) \ @@ -329,7 +329,7 @@ int cParsedNBT::FindTagByPath(int a_Tag, const AString & a_Path) const -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cFastNBTWriter: cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) : diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 181cfde0d..5a2be8867 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -72,7 +72,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB for (int explosiontag = a_NBT.GetFirstChild(a_TagIdx); explosiontag >= 0; explosiontag = a_NBT.GetNextSibling(explosiontag)) { eTagType TagType = a_NBT.GetType(explosiontag); - if (TagType == TAG_Byte) // Custon name tag + if (TagType == TAG_Byte) // Custon name tag { AString ExplosionName = a_NBT.GetName(explosiontag); @@ -135,7 +135,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB for (int fireworkstag = a_NBT.GetFirstChild(a_TagIdx); fireworkstag >= 0; fireworkstag = a_NBT.GetNextSibling(fireworkstag)) { eTagType TagType = a_NBT.GetType(fireworkstag); - if (TagType == TAG_Byte) // Custon name tag + if (TagType == TAG_Byte) // Custon name tag { if (a_NBT.GetName(fireworkstag) == "Flight") { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 6d0b60371..3f79a6572 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -279,7 +279,7 @@ void cNBTChunkSerializer::AddCommandBlockEntity(cCommandBlockEntity * a_CmdBlock m_Writer.AddString("Command", a_CmdBlock->GetCommand()); m_Writer.AddInt ("SuccessCount", a_CmdBlock->GetResult()); m_Writer.AddString("LastOutput", a_CmdBlock->GetLastOutput()); - m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it. + m_Writer.AddByte ("TrackOutput", 1); // TODO 2014-01-18 xdot: Figure out what TrackOutput is and save it. m_Writer.EndCompound(); } diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index 1cf99efd9..64f4cb00d 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -44,7 +44,7 @@ public: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cSchematicFileSerializer: bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName) diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp index 6c885bb45..da8236e0d 100644 --- a/src/WorldStorage/ScoreboardSerializer.cpp +++ b/src/WorldStorage/ScoreboardSerializer.cpp @@ -117,7 +117,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) a_Writer.EndCompound(); } - a_Writer.EndList(); // Objectives + a_Writer.EndList(); // Objectives a_Writer.BeginList("PlayerScores", TAG_Compound); @@ -138,7 +138,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) } } - a_Writer.EndList(); // PlayerScores + a_Writer.EndList(); // PlayerScores a_Writer.BeginList("Teams", TAG_Compound); @@ -169,7 +169,7 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) a_Writer.EndCompound(); } - a_Writer.EndList(); // Teams + a_Writer.EndList(); // Teams a_Writer.BeginCompound("DisplaySlots"); @@ -182,9 +182,9 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer) Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsName); a_Writer.AddString("slot_2", (Objective == NULL) ? "" : Objective->GetName()); - a_Writer.EndCompound(); // DisplaySlots + a_Writer.EndCompound(); // DisplaySlots - a_Writer.EndCompound(); // Data + a_Writer.EndCompound(); // Data } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 1a43cf4ba..388ad0332 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -69,7 +69,7 @@ Since only the header is actually in the memory, this number can be high, but st -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSAnvil: cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : @@ -1356,7 +1356,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - std::auto_ptr Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height + std::auto_ptr Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) { return; @@ -1465,7 +1465,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a return; } - std::auto_ptr Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false + std::auto_ptr Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx)) { return; @@ -2592,7 +2592,7 @@ bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSAnvil::cMCAFile: cWSSAnvil::cMCAFile::cMCAFile(const AString & a_FileName, int a_RegionX, int a_RegionZ) : diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index a3ba443fd..3b08c5ac5 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -48,7 +48,7 @@ const int MAX_DIRTY_CHUNKS = 16; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cJsonChunkSerializer: cJsonChunkSerializer::cJsonChunkSerializer(void) : @@ -120,7 +120,7 @@ void cJsonChunkSerializer::LightIsValid(bool a_IsLightValid) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSCompact: cWSSCompact::~cWSSCompact() @@ -411,7 +411,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWSSCompact::cPAKFile #define READ(Var) \ @@ -427,7 +427,7 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ m_LayerX(a_LayerX), m_LayerZ(a_LayerZ), m_NumDirty(0), - m_ChunkVersion( CHUNK_VERSION ), // Init with latest version + m_ChunkVersion( CHUNK_VERSION ), // Init with latest version m_PakVersion( PAK_VERSION ) { cFile f; @@ -486,12 +486,12 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_ return; } - if( m_ChunkVersion == 1 ) // Convert chunks to version 2 + if( m_ChunkVersion == 1 ) // Convert chunks to version 2 { UpdateChunk1To2(); } #if AXIS_ORDER == AXIS_ORDER_XZY - if( m_ChunkVersion == 2 ) // Convert chunks to version 3 + if( m_ChunkVersion == 2 ) // Convert chunks to version 3 { UpdateChunk2To3(); } @@ -586,7 +586,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Offset += Header->m_CompressedSize; // Crude data integrity check: - int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1 + int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1 if (UncompressedSize < ExpectedSize) { LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing", @@ -638,7 +638,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 128; } InChunkOffset += (16 * 128 * 16); - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata { for( int y = 0; y < 64; ++y ) { @@ -648,7 +648,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16 * 128 * 16) / 2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light { for( int y = 0; y < 64; ++y ) { @@ -658,7 +658,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() Index += 64; } InChunkOffset += (16*128*16)/2; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light { for( int y = 0; y < 64; ++y ) { @@ -774,7 +774,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() #define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) ) unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X { ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset]; ++InChunkOffset; diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index b148005f6..83e9cb49f 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -105,15 +105,15 @@ protected: int m_NumDirty; // Number of chunks that were written into m_DataContents but not into the file - Vector3i m_ChunkSize; // Is related to m_ChunkVersion + Vector3i m_ChunkSize; // Is related to m_ChunkVersion char m_ChunkVersion; char m_PakVersion; bool SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World); // Saves the chunk to m_DataContents, updates headers and m_NumDirty void SynchronizeFile(void); // Writes m_DataContents along with the headers to file, resets m_NumDirty - void UpdateChunk1To2(void); // Height from 128 to 256 - void UpdateChunk2To3(void); // Axis order from YZX to XZY + void UpdateChunk1To2(void); // Height from 128 to 256 + void UpdateChunk2To3(void); // Axis order from YZX to XZY } ; typedef std::list cPAKFiles; diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index d3f35384b..b6d572f3e 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -35,7 +35,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cWorldStorage: cWorldStorage::cWorldStorage(void) : @@ -96,7 +96,7 @@ void cWorldStorage::WaitForFinish(void) // Wait for the thread to finish: m_ShouldTerminate = true; - m_Event.Set(); // Wake up the thread if waiting + m_Event.Set(); // Wake up the thread if waiting super::Wait(); LOG("World storage thread finished"); } diff --git a/src/XMLParser.h b/src/XMLParser.h index 28fa05579..e39405529 100644 --- a/src/XMLParser.h +++ b/src/XMLParser.h @@ -55,7 +55,7 @@ protected: -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // The following template has been modified from code available at // http://www.codeproject.com/Articles/1847/C-Wrappers-for-the-Expat-XML-Parser // It uses templates to remove the virtual function call penalty (both size and speed) for each callback diff --git a/src/main.cpp b/src/main.cpp index f485d8f8f..0ff9361be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,7 +88,7 @@ void NonCtrlHandler(int a_Signal) #if defined(_WIN32) && !defined(_WIN64) && defined(_MSC_VER) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Windows 32-bit stuff: when the server crashes, create a "dump file" containing the callstack of each thread and some variables; let the user send us that crash file for analysis typedef BOOL (WINAPI *pMiniDumpWriteDump)( @@ -171,7 +171,7 @@ BOOL CtrlHandler(DWORD fdwCtrlType) -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // main: int main( int argc, char **argv ) From a02509ff4b29a03fd396ff62a2b19ac96f71ef39 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:19:52 +0200 Subject: [PATCH 261/280] Initial version of a script to check basic style. This script reports basic violations of the style, such as indentation using spaces, alignment using tabs, trailing whitespace etc. Passing this script does NOT mean that the style is clean, it's only for fast-checking purposes. --- src/CheckBasicStyle.lua | 188 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 src/CheckBasicStyle.lua diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua new file mode 100644 index 000000000..f9bb41975 --- /dev/null +++ b/src/CheckBasicStyle.lua @@ -0,0 +1,188 @@ + +-- CheckBasicStyle.lua + +--[[ +Checks that all source files (*.cpp, *.h) use the basic style requirements of the project: + - Tabs for indentation, spaces for alignment + - Trailing whitespace on non-empty lines + - Two spaces between code and line-end comment ("//") + - (TODO) Spaces around +, -, (cannot check /, * or & due to their other usage - comment, ptr deref, address-of) + - (TODO) Spaces before *, /, & + - (TODO) Spaces after , + - (TODO) Hex numbers with even digit length + - (TODO) Hex numbers in lowercase + - (TODO) Braces not on the end of line + - (TODO) Line dividers (////...) exactly 80 slashes + +Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking +the line brings the editor directly to the violation. + +Returns 0 on success, 1 on internal failure, 2 if any violations found + +This script requires LuaFileSystem to be available in the current Lua interpreter. +--]] + + + + + +-- Check that LFS is installed: +local hasLfs = pcall(require, "lfs") +if not(hasLfs) then + print("This script requires LuaFileSystem to be installed") + os.exit(1) +end +local lfs = require("lfs") +assert(lfs ~= nil) + + + + + +-- The list of file extensions that are processed: +local g_ShouldProcessExt = +{ + ["h"] = true, + ["cpp"] = true, +} + +--- The list of files not to be processed: +local g_IgnoredFiles = +{ + "./Bindings/Bindings.cpp", + "./Bindings/DeprecatedBindings.cpp", + "./LeakFinder.cpp", + "./LeakFinder.h", + "./MersenneTwister.h", + "./StackWalker.cpp", + "./StackWalker.h", +} + +--- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles +local g_ShouldIgnoreFile = {} + +-- Initialize the g_ShouldIgnoreFile map: +for _, fnam in ipairs(g_IgnoredFiles) do + g_ShouldIgnoreFile[fnam] = true +end + +--- Keeps track of the number of violations for this folder +local g_NumViolations = 0 + + + + + +--- Reports one violation +-- Pretty-prints the message +-- Also increments g_NumViolations +local function ReportViolation(a_FileName, a_LineNumber, a_Message) + print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_Message) + g_NumViolations = g_NumViolations + 1 +end + + + + + +--- Processes one file +local function ProcessFile(a_FileName) + assert(type(a_FileName) == "string") + + -- Read the whole file: + local f, err = io.open(a_FileName, "r") + if (f == nil) then + print("Cannot open file \"" .. a_FileName .. "\": " .. err) + print("Aborting") + os.exit(1) + end + local all = f:read("*all") + + -- Check that the last line is empty - otherwise processing won't work properly: + local lastChar = string.byte(all, string.len(all)) + if ((lastChar ~= 13) and (lastChar ~= 10)) then + local numLines = 1 + string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends + ReportViolation(a_FileName, numLines, "Missing empty line at file end") + return + end + + -- Process each line separately: + -- Ref.: http://stackoverflow.com/questions/10416869/iterate-over-possibly-empty-lines-in-a-way-that-matches-the-expectations-of-exis + local lineCounter = 1 + all:gsub("\r\n", "\n") -- normalize CRLF into LF-only + string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines + function(a_Line) + -- Check against indenting using spaces: + if (a_Line:find("^\t* +")) then -- Find any number of tabs at the start of line (incl 0), followed by a space + ReportViolation(a_FileName, lineCounter, "Indenting with a space") + end + -- Check against alignment using tabs: + if (a_Line:find("[^%s]\t+[^%s]")) then -- Find any number of tabs after non-whitespace followed by non-whitespace + ReportViolation(a_FileName, lineCounter, "Aligning with a tab") + end + -- Check against trailing whitespace: + if (a_Line:find("[^%s]%s+\n")) then -- Find any whitespace after non-whitespace at the end of line + ReportViolation(a_FileName, lineCounter, "Trailing whitespace") + end + -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): + if (a_Line:find("[^%s] //")) then + ReportViolation(a_FileName, lineCounter, "Needs at least two spaces in front of a \"//\"-style comment") + end + -- Check that all "//"-style comments have at least one spaces after: + if (a_Line:find("%s//[^%s/*<]")) then + ReportViolation(a_FileName, lineCounter, "Needs a space after a \"//\"-style comment") + end + lineCounter = lineCounter + 1 + end + ) +end + + + + + +--- Processes one item - a file or a folder +local function ProcessItem(a_ItemName) + assert(type(a_ItemName) == "string") + + -- Skip files / folders that should be ignored + if (g_ShouldIgnoreFile[a_ItemName]) then + return + end + + -- If the item is a folder, recurse: + local attrs = lfs.attributes(a_ItemName) + if (attrs and (attrs.mode == "directory")) then + for fnam in lfs.dir(a_ItemName) do + if ((fnam ~= ".") and (fnam ~= "..")) then + ProcessItem(a_ItemName .. "/" .. fnam) + end + end + return + end + + local ext = a_ItemName:match("%.([^/%.]-)$") + if (g_ShouldProcessExt[ext]) then + ProcessFile(a_ItemName) + end +end + + + + + +-- Process the entire current folder: +ProcessItem(".") + +-- Report final verdict: +print("Number of violations found: " .. g_NumViolations) +if (g_NumViolations > 0) then + os.exit(2) +else + os.exit(0) +end + + + + From 5e198c673009cf8ca9d92cf59848999bc96bbc37 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:50:58 +0200 Subject: [PATCH 262/280] Basic style fixes. --- src/Bindings/ManualBindings.cpp | 27 ++++++++--------- src/Bindings/Plugin.h | 7 ++--- src/Bindings/PluginLua.cpp | 14 ++++----- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/PluginManager.h | 24 ++++++++------- src/Bindings/WebPlugin.cpp | 20 ++++++++----- src/BlockEntities/BeaconEntity.cpp | 2 +- src/BlockEntities/ChestEntity.cpp | 2 +- src/BlockEntities/CommandBlockEntity.h | 2 +- src/BlockEntities/DropSpenserEntity.cpp | 2 +- src/BlockEntities/EnderChestEntity.h | 4 +-- src/BlockEntities/FlowerPotEntity.h | 2 +- src/BlockEntities/JukeboxEntity.h | 2 +- src/BlockEntities/MobHeadEntity.h | 2 +- src/BlockEntities/NoteEntity.h | 2 +- src/BlockEntities/SignEntity.h | 2 +- src/Blocks/BlockAnvil.h | 2 +- src/Blocks/BlockBed.cpp | 4 +-- src/Blocks/BlockBigFlower.h | 4 +-- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockCarpet.h | 2 +- src/Blocks/BlockChest.h | 4 +-- src/Blocks/BlockCrops.h | 2 +- src/Blocks/BlockDoor.cpp | 4 +-- src/Blocks/BlockDoor.h | 2 +- src/Blocks/BlockDropSpenser.h | 2 +- src/Blocks/BlockFenceGate.h | 2 +- src/Blocks/BlockFluid.h | 2 +- src/Blocks/BlockFurnace.h | 4 +-- src/Blocks/BlockHandler.cpp | 4 +-- src/Blocks/BlockHandler.h | 22 +++++++------- src/Blocks/BlockHopper.h | 2 +- src/Blocks/BlockIce.h | 2 +- src/Blocks/BlockLeaves.h | 8 ++--- src/Blocks/BlockLever.h | 2 +- src/Blocks/BlockMobHead.h | 4 +-- src/Blocks/BlockPiston.cpp | 2 +- src/Blocks/BlockPiston.h | 4 +-- src/Blocks/BlockPlanks.h | 2 +- src/Blocks/BlockPortal.h | 2 +- src/Blocks/BlockPumpkin.h | 4 +-- src/Blocks/BlockQuartz.h | 2 +- src/Blocks/BlockRail.h | 22 +++++++------- src/Blocks/BlockSideways.h | 2 +- src/Blocks/BlockSign.h | 2 +- src/Blocks/BlockSlab.h | 2 +- src/Blocks/BlockSnow.h | 2 +- src/Blocks/BlockStairs.h | 2 +- src/Blocks/BlockTorch.h | 2 +- src/Blocks/BlockVine.h | 2 +- src/Blocks/BroadcastInterface.h | 2 +- src/Blocks/ChunkInterface.h | 2 +- src/Blocks/ClearMetaOnDrop.h | 2 +- src/Blocks/MetaRotator.h | 6 ++-- src/Blocks/WorldInterface.h | 2 +- src/Entities/ArrowEntity.cpp | 4 +-- src/Entities/Boat.cpp | 2 +- src/Entities/Entity.cpp | 30 +++++++++---------- src/Entities/Entity.h | 2 +- src/Entities/Minecart.h | 2 +- src/Entities/Player.cpp | 10 +++---- src/Entities/Player.h | 4 +-- src/Entities/ProjectileEntity.h | 4 +-- src/Generating/ChunkDesc.h | 2 +- src/Generating/CompoGen.cpp | 4 +-- src/Generating/ComposableGenerator.cpp | 6 ++-- src/Generating/FinishGen.cpp | 4 +-- src/Generating/HeiGen.cpp | 2 +- src/Generating/PieceGenerator.cpp | 2 +- src/Generating/PieceGenerator.h | 4 +-- src/Generating/Prefab.cpp | 2 +- src/Generating/Prefab.h | 2 +- src/Generating/StructGen.cpp | 14 ++++----- src/Generating/Trees.cpp | 8 ++--- src/HTTPServer/HTTPMessage.cpp | 2 +- src/Items/ItemBed.h | 2 +- src/Items/ItemBrewingStand.h | 2 +- src/Items/ItemCake.h | 2 +- src/Items/ItemCauldron.h | 2 +- src/Items/ItemComparator.h | 2 +- src/Items/ItemDoor.h | 6 ++-- src/Items/ItemFishingRod.h | 2 +- src/Items/ItemFlowerPot.h | 2 +- src/Items/ItemHandler.cpp | 6 ++-- src/Items/ItemHandler.h | 4 +-- src/Items/ItemLeaves.h | 2 +- src/Items/ItemMobHead.h | 2 +- src/Items/ItemNetherWart.h | 2 +- src/Items/ItemRedstoneDust.h | 2 +- src/Items/ItemRedstoneRepeater.h | 2 +- src/Items/ItemSapling.h | 2 +- src/Items/ItemSeeds.h | 4 +-- src/Items/ItemSign.h | 2 +- src/Items/ItemSugarcane.h | 2 +- src/Mobs/AggressiveMonster.cpp | 2 +- src/Mobs/Monster.cpp | 6 ++-- src/Mobs/Monster.h | 8 ++--- src/Mobs/Villager.cpp | 2 +- src/OSSupport/CriticalSection.cpp | 4 +-- src/OSSupport/CriticalSection.h | 2 +- src/OSSupport/Queue.h | 4 +-- src/OSSupport/Socket.cpp | 4 +-- src/Protocol/Authenticator.cpp | 2 +- src/Protocol/Protocol125.cpp | 4 +-- src/Protocol/Protocol132.cpp | 2 +- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/ProtocolRecognizer.cpp | 6 ++-- src/Protocol/ProtocolRecognizer.h | 2 +- src/Simulator/DelayedFluidSimulator.cpp | 2 +- src/Simulator/DelayedFluidSimulator.h | 2 +- src/Simulator/FireSimulator.cpp | 4 +-- src/Simulator/FloodyFluidSimulator.cpp | 10 +++---- .../IncrementalRedstoneSimulator.cpp | 14 ++++----- src/Simulator/NoopFluidSimulator.h | 2 +- src/Simulator/NoopRedstoneSimulator.h | 2 +- src/Simulator/SandSimulator.h | 2 +- src/Simulator/Simulator.h | 2 +- src/Simulator/VaporizeFluidSimulator.cpp | 2 +- src/UI/SlotArea.cpp | 6 ++-- src/UI/Window.cpp | 2 +- src/UI/Window.h | 6 ++-- src/UI/WindowOwner.h | 2 +- src/WorldStorage/FastNBT.cpp | 4 +-- src/WorldStorage/FastNBT.h | 6 ++-- src/WorldStorage/FireworksSerializer.cpp | 4 +-- src/WorldStorage/WSSAnvil.cpp | 12 ++++---- src/WorldStorage/WSSCompact.cpp | 12 ++++---- src/WorldStorage/WorldStorage.cpp | 2 +- src/WorldStorage/WorldStorage.h | 4 +-- 130 files changed, 290 insertions(+), 286 deletions(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index bb059193b..530101d47 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -33,9 +33,7 @@ -/**************************** - * Better error reporting for Lua - **/ +// Better error reporting for Lua static int tolua_do_error(lua_State* L, const char * a_pMsg, tolua_Error * a_pToLuaError) { // Retrieve current function name @@ -81,10 +79,7 @@ static int lua_do_error(lua_State* L, const char * a_pFormat, ...) -/**************************** - * Lua bound functions with special return types - **/ - +// Lua bound functions with special return types static int tolua_StringSplit(lua_State * tolua_S) { cLuaState LuaState(tolua_S); @@ -557,10 +552,12 @@ static int tolua_DoWithXYZ(lua_State* tolua_S) -template< class Ty1, - class Ty2, - bool (Ty1::*Func1)(int, int, cItemCallback &) > -static int tolua_ForEachInChunk(lua_State* tolua_S) +template< + class Ty1, + class Ty2, + bool (Ty1::*Func1)(int, int, cItemCallback &) +> +static int tolua_ForEachInChunk(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ if ((NumArgs != 3) && (NumArgs != 4)) @@ -651,9 +648,11 @@ static int tolua_ForEachInChunk(lua_State* tolua_S) -template< class Ty1, - class Ty2, - bool (Ty1::*Func1)(cItemCallback &) > +template< + class Ty1, + class Ty2, + bool (Ty1::*Func1)(cItemCallback &) +> static int tolua_ForEach(lua_State * tolua_S) { int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */ diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 0a0534724..fc8aa1cdb 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -42,10 +42,7 @@ public: // Called each tick virtual void Tick(float a_Dt) = 0; - /** - * On all these functions, return true if you want to override default behavior and not call other plugins on that callback. - * You can also return false, so default behavior is used. - **/ + /** Calls the specified hook with the params given. Returns the bool that the hook callback returns.*/ virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0; virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0; virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0; @@ -152,7 +149,7 @@ private: int m_Version; AString m_Directory; -}; // tolua_export +}; // tolua_export diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index f69435370..5fa8adc66 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -78,7 +78,7 @@ bool cPluginLua::Initialize(void) { cCSLock Lock(m_CriticalSection); if (!m_LuaState.IsValid()) - { + { m_LuaState.Create(); m_LuaState.RegisterAPILibs(); @@ -1015,7 +1015,7 @@ bool cPluginLua::OnPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_Block -bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) +bool cPluginLua::OnPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { cCSLock Lock(m_CriticalSection); bool res = false; @@ -1294,8 +1294,8 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI) bool cPluginLua::OnUpdatedSign( - cWorld * a_World, - int a_BlockX, int a_BlockY, int a_BlockZ, + cWorld * a_World, + 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 ) @@ -1319,8 +1319,8 @@ bool cPluginLua::OnUpdatedSign( bool cPluginLua::OnUpdatingSign( - cWorld * a_World, - int a_BlockX, int a_BlockY, int a_BlockZ, + cWorld * a_World, + int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player ) @@ -1517,7 +1517,7 @@ bool cPluginLua::CanAddOldStyleHook(int a_HookType) return true; } - LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.", + LOGWARNING("Plugin %s wants to add a hook (%d), but it doesn't provide the callback function \"%s\" for it. The plugin need not work properly.", GetName().c_str(), a_HookType, FnName ); m_LuaState.LogStackTrace(); diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 4a9634c09..b2979a210 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -145,7 +145,7 @@ public: // cWebPlugin and WebAdmin stuff virtual AString HandleWebRequest(const HTTPRequest * a_Request ) override; - bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS << + bool AddWebTab(const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference); // >> EXPORTED IN MANUALBINDINGS << /** Binds the command to call the function specified by a Lua function reference. Simply adds to CommandMap. */ void BindCommand(const AString & a_Command, int a_FnRef); diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 6b5e60dcc..2c0ce701b 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1486,7 +1486,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName) if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does? { m_DisablePluginList.push_back(itr->second); - itr->second = NULL; // Get rid of this thing right away + itr->second = NULL; // Get rid of this thing right away return true; } return false; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index bf181a55f..cffd8d04b 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -51,10 +51,12 @@ class cBlockEntityWithItems; -class cPluginManager // tolua_export -{ // tolua_export -public: // tolua_export - +// tolua_begin +class cPluginManager +{ +public: + // tolua_end + // Called each tick virtual void Tick(float a_Dt); @@ -157,15 +159,17 @@ public: // tolua_export /** Returns the instance of the Plugin Manager (there is only ever one) */ - static cPluginManager * Get(void); // tolua_export + static cPluginManager * Get(void); // tolua_export typedef std::map< AString, cPlugin * > PluginMap; typedef std::list< cPlugin * > PluginList; - cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export - const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << + cPlugin * GetPlugin( const AString & a_Plugin ) const; // tolua_export + const PluginMap & GetAllPlugins() const; // >> EXPORTED IN MANUALBINDINGS << - void FindPlugins(); // tolua_export - void ReloadPlugins(); // tolua_export + // tolua_begin + void FindPlugins(); + void ReloadPlugins(); + // tolua_end /** Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add */ void AddHook(cPlugin * a_Plugin, int a_HookType); @@ -335,7 +339,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 crExecuted if the command is executed. */ - cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); + cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions); } ; // tolua_export diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp index bc1a9ac8c..57ed9f6a4 100644 --- a/src/Bindings/WebPlugin.cpp +++ b/src/Bindings/WebPlugin.cpp @@ -64,27 +64,27 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest std::pair< AString, AString > Names; AStringVector Split = StringSplit(a_Request->Path, "/"); - if( Split.size() > 1 ) + if (Split.size() > 1) { - sWebPluginTab* Tab = 0; - if( Split.size() > 2 ) // If we got the tab name, show that page + sWebPluginTab * Tab = NULL; + if (Split.size() > 2) // If we got the tab name, show that page { for( TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr ) { - if( (*itr)->SafeTitle.compare( Split[2] ) == 0 ) // This is the one! Rawr + if ((*itr)->SafeTitle.compare(Split[2]) == 0) // This is the one! { Tab = *itr; break; } } } - else // Otherwise show the first tab + else // Otherwise show the first tab { if( GetTabs().size() > 0 ) Tab = *GetTabs().begin(); } - if( Tab ) + if (Tab != NULL) { Names.first = Tab->Title; Names.second = Tab->SafeTitle; @@ -97,13 +97,13 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest -AString cWebPlugin::SafeString( const AString & a_String ) +AString cWebPlugin::SafeString(const AString & a_String) { AString RetVal; for( unsigned int i = 0; i < a_String.size(); ++i ) { char c = a_String[i]; - if( c == ' ' ) + if( c == ' ' ) { c = '_'; } @@ -111,3 +111,7 @@ AString cWebPlugin::SafeString( const AString & a_String ) } return RetVal; } + + + + diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 0914353eb..9a6d85f1d 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -32,7 +32,7 @@ int cBeaconEntity::GetPyramidLevel(void) } Area.Read( - m_World, + m_World, GetPosX() - 4, GetPosX() + 4, MinY, MaxY, GetPosZ() - 4, GetPosZ() + 4, diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index ca164464c..9f50365e9 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -177,7 +177,7 @@ void cChestEntity::OpenNewWindow(void) return; } - // There is no chest neighbor, open a single-chest window: + // There is no chest neighbor, open a single-chest window: OpenWindow(new cChestWindow(this)); } diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index 12157670f..d7c4eaabe 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -26,7 +26,7 @@ namespace Json // tolua_begin -class cCommandBlockEntity : +class cCommandBlockEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp index 0fa6bbe69..dc38e3e9b 100644 --- a/src/BlockEntities/DropSpenserEntity.cpp +++ b/src/BlockEntities/DropSpenserEntity.cpp @@ -99,7 +99,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) } m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir); m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f); -} +} diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h index 04af67683..ed178f6fc 100644 --- a/src/BlockEntities/EnderChestEntity.h +++ b/src/BlockEntities/EnderChestEntity.h @@ -16,10 +16,10 @@ class cEnderChestEntity : { typedef cBlockEntity super; -public: +public: // tolua_end - 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"; } diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index e3570eb9a..85cb810ad 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -27,7 +27,7 @@ namespace Json // tolua_begin -class cFlowerPotEntity : +class cFlowerPotEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 3d1d604f7..8bb3009eb 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -19,7 +19,7 @@ namespace Json // tolua_begin -class cJukeboxEntity : +class cJukeboxEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h index 367eb15e7..2bc072d69 100644 --- a/src/BlockEntities/MobHeadEntity.h +++ b/src/BlockEntities/MobHeadEntity.h @@ -25,7 +25,7 @@ namespace Json // tolua_begin -class cMobHeadEntity : +class cMobHeadEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index b698899c0..07b8fd259 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -28,7 +28,7 @@ enum ENUM_NOTE_INSTRUMENTS // tolua_begin -class cNoteEntity : +class cNoteEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 80c7bbfdf..16e0e23bc 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -25,7 +25,7 @@ namespace Json // tolua_begin -class cSignEntity : +class cSignEntity : public cBlockEntity { typedef cBlockEntity super; diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index 35a356678..5c4661c11 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -34,7 +34,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index 32b5133c7..fbf98044c 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -116,7 +116,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface if (Meta & 0x8) { - // Is pillow + // Is pillow a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX, a_BlockY, a_BlockZ); } else @@ -142,7 +142,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface a_WorldInterface.SetTimeOfDay(0); a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0xB); // Where 0xB = 1011, and zero is to make sure 'occupied' bit is always unset } - } + } } else { diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h index 39fd3cac8..ff9825a83 100644 --- a/src/Blocks/BlockBigFlower.h +++ b/src/Blocks/BlockBigFlower.h @@ -86,8 +86,8 @@ public: virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 9fc5e4626..3b45afff8 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -46,7 +46,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockCarpet.h b/src/Blocks/BlockCarpet.h index 33dc1da6c..d1aa52687 100644 --- a/src/Blocks/BlockCarpet.h +++ b/src/Blocks/BlockCarpet.h @@ -32,7 +32,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index f899f4bcb..28adbed4f 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -22,7 +22,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 @@ -68,7 +68,7 @@ public: virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, + 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 diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h index 8606cf3f3..ae6e490e1 100644 --- a/src/Blocks/BlockCrops.h +++ b/src/Blocks/BlockCrops.h @@ -71,7 +71,7 @@ public: } } } - } + } virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index 934a01994..e80473cb5 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -152,7 +152,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta) // Return a_Meta if panel is a top panel (0x08 bit is set to 1) // Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored - // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, + // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, // so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself // needs extra datamembers. if (a_Meta & 0x08) return a_Meta; @@ -179,7 +179,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta) // Return a_Meta if panel is a top panel (0x08 bit is set to 1) // Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored - // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, + // in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time, // so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself // needs extra datamembers. diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 049c4a334..c86fe829b 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -28,7 +28,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index cf240fa60..ba96c716a 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h index e992870d4..433531275 100644 --- a/src/Blocks/BlockFenceGate.h +++ b/src/Blocks/BlockFenceGate.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index d0c4ea55b..8c0aae041 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -17,7 +17,7 @@ public: : cBlockHandler(a_BlockType) { - } + } virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h index 74582c3b3..2c7310ac9 100644 --- a/src/Blocks/BlockFurnace.h +++ b/src/Blocks/BlockFurnace.h @@ -13,7 +13,7 @@ class cBlockFurnaceHandler : public cMetaRotator { public: - cBlockFurnaceHandler(BLOCKTYPE a_BlockType) + cBlockFurnaceHandler(BLOCKTYPE a_BlockType) : cMetaRotator(a_BlockType) { } @@ -27,7 +27,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index cef1f5f09..97762f9bd 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -176,7 +176,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) { switch(a_BlockType) { - // Block handlers, alphabetically sorted: + // 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); @@ -327,7 +327,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType) bool cBlockHandler::GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 ) diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index fb6cae729..7f23fc6ff 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -30,14 +30,14 @@ public: /// Note that the coords are chunk-relative! virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ); - /** Called before a block is placed into a world. + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block */ virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 ); @@ -47,8 +47,8 @@ public: /// Called by cClientHandle::HandlePlaceBlock() after the player has placed a new block. Called after OnPlaced(). virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 ); @@ -90,7 +90,7 @@ public: virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta); /** Checks if the block can be placed at this point. - Default: CanBeAt(...) + Default: CanBeAt(...) NOTE: This call doesn't actually place the block */ // virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); @@ -98,27 +98,27 @@ public: /// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called virtual bool IsUseable(void); - /** Indicates whether the client will click through this block. + /** Indicates whether the client will click through this block. For example digging a fire will hit the block below the fire so fire is clicked through */ virtual bool IsClickedThrough(void); - /** Checks if the player can build "inside" this block. + /** Checks if the player can build "inside" this block. For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision */ virtual bool DoesIgnoreBuildCollision(void); /// Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow) - virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta) - { + virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta) + { UNUSED(a_Meta); - return DoesIgnoreBuildCollision(); + return DoesIgnoreBuildCollision(); } /// Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true virtual bool DoesDropOnUnsuitable(void); - /** Called when one of the neighbors gets set; equivalent to MC block update. + /** Called when one of the neighbors gets set; equivalent to MC block update. By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()), and wakes up all simulators on the block. */ diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h index a882bb077..4a5d32dd5 100644 --- a/src/Blocks/BlockHopper.h +++ b/src/Blocks/BlockHopper.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h index 8dfe7ddac..c50623594 100644 --- a/src/Blocks/BlockIce.h +++ b/src/Blocks/BlockIce.h @@ -29,7 +29,7 @@ public: // TODO: Ice destroyed with air below it should turn into air instead of water a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, 0); // This is called later than the real destroying of this ice block - } + } } ; diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h index 260abefc7..d0baab013 100644 --- a/src/Blocks/BlockLeaves.h +++ b/src/Blocks/BlockLeaves.h @@ -100,10 +100,10 @@ public: int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; cBlockArea Area; if (!Area.Read( - a_Chunk.GetWorld(), - BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE, - a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE, - BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE, + a_Chunk.GetWorld(), + BlockX - LEAVES_CHECK_DISTANCE, BlockX + LEAVES_CHECK_DISTANCE, + a_RelY - LEAVES_CHECK_DISTANCE, a_RelY + LEAVES_CHECK_DISTANCE, + BlockZ - LEAVES_CHECK_DISTANCE, BlockZ + LEAVES_CHECK_DISTANCE, cBlockArea::baTypes) ) { diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 7ce8d038e..4316fd06b 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -43,7 +43,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 301386568..ff1ef97bf 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -193,8 +193,8 @@ public: } virtual void OnPlacedByPlayer( - cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 6ffb56abd..164967621 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -62,7 +62,7 @@ void cBlockPistonHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorld bool cBlockPistonHandler::GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 ) diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 307539476..bbb8af75b 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -17,7 +17,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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; @@ -75,7 +75,7 @@ public: return BLOCK_FACE_NONE; } } - } + } static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h index 2a99a455e..de84ed319 100644 --- a/src/Blocks/BlockPlanks.h +++ b/src/Blocks/BlockPlanks.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index d58b2f09d..9ee5d69e2 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index 4692a47df..15ac80fd7 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -76,14 +76,14 @@ public: a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0); // Spawn the golem: - a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem); + a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem); } } virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index 1b1f6f9f0..2ce7e71e4 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index 6f3fa1bd5..87ce069ab 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -31,7 +31,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 @@ -223,7 +223,7 @@ public: case E_META_RAIL_ZM_ZP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_DOWN) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_DOWN) ) { @@ -235,7 +235,7 @@ public: case E_META_RAIL_XM_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST, E_PURE_DOWN) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST, E_PURE_DOWN) ) { @@ -247,7 +247,7 @@ public: case E_META_RAIL_ASCEND_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_EAST) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -259,7 +259,7 @@ public: case E_META_RAIL_ASCEND_XM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -271,7 +271,7 @@ public: case E_META_RAIL_ASCEND_ZM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) ) { @@ -283,7 +283,7 @@ public: case E_META_RAIL_ASCEND_ZP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH) ) { @@ -295,7 +295,7 @@ public: case E_META_RAIL_CURVED_ZP_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ) { @@ -307,7 +307,7 @@ public: case E_META_RAIL_CURVED_ZP_XM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_SOUTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -319,7 +319,7 @@ public: case E_META_RAIL_CURVED_ZM_XM: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_WEST) ) { @@ -331,7 +331,7 @@ public: case E_META_RAIL_CURVED_ZM_XP: { if ( - IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || + IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NORTH) || IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_EAST) ) { diff --git a/src/Blocks/BlockSideways.h b/src/Blocks/BlockSideways.h index 9cbd4cf97..f5f10899d 100644 --- a/src/Blocks/BlockSideways.h +++ b/src/Blocks/BlockSideways.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockSign.h b/src/Blocks/BlockSign.h index f5630bdb0..5aa8ade3d 100644 --- a/src/Blocks/BlockSign.h +++ b/src/Blocks/BlockSign.h @@ -59,7 +59,7 @@ public: } } return 0x2; - } + } virtual void OnPlacedByPlayer( diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 6c861be86..214445eda 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -33,7 +33,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index c5ae4a5a6..27fc17e7f 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index e74ab0094..a7ccf1714 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h index 554ab8125..73f2bf9a8 100644 --- a/src/Blocks/BlockTorch.h +++ b/src/Blocks/BlockTorch.h @@ -19,7 +19,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index 7bb9dc484..c2d82eb4d 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -18,7 +18,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Blocks/BroadcastInterface.h b/src/Blocks/BroadcastInterface.h index fbe72e72f..c8593c76a 100644 --- a/src/Blocks/BroadcastInterface.h +++ b/src/Blocks/BroadcastInterface.h @@ -1,7 +1,7 @@ #pragma once -class cBroadcastInterface +class cBroadcastInterface { public: virtual ~cBroadcastInterface() {} diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h index be7c2e0e5..f9cbe3a2d 100644 --- a/src/Blocks/ChunkInterface.h +++ b/src/Blocks/ChunkInterface.h @@ -21,7 +21,7 @@ public: return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ); } BLOCKTYPE GetBlock(const Vector3i & a_Pos) - { + { return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z); } NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ) diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h index 3f8c33819..f2afbc6ea 100644 --- a/src/Blocks/ClearMetaOnDrop.h +++ b/src/Blocks/ClearMetaOnDrop.h @@ -4,7 +4,7 @@ // 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 +// For example to use in class Foo which should inherit Bar use // class Foo : public cClearMetaOnDrop; template diff --git a/src/Blocks/MetaRotator.h b/src/Blocks/MetaRotator.h index ad8f36183..599aa7ef9 100644 --- a/src/Blocks/MetaRotator.h +++ b/src/Blocks/MetaRotator.h @@ -47,8 +47,8 @@ NIBBLETYPE cMetaRotatorGetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT))) { if (GetSpeedY() < 2) - { + { AddSpeedY(0.2); } } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index bb584cb9e..0ff3ff102 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -74,7 +74,7 @@ cEntity::~cEntity() /* // DEBUG: - LOGD("Deleting entity %d at pos {%.2f, %.2f, %.2f} ~ [%d, %d]; ptr %p", + LOGD("Deleting entity %d at pos {%.2f, %.2f, %.2f} ~ [%d, %d]; ptr %p", m_UniqueID, m_Pos.x, m_Pos.y, m_Pos.z, (int)(m_Pos.x / cChunkDef::Width), (int)(m_Pos.z / cChunkDef::Width), @@ -1090,7 +1090,7 @@ void cEntity::HandleAir(void) { if (m_AirTickTimer < 1) { - // Damage player + // Damage player TakeDamage(dtDrowning, NULL, 1, 1, 0); // Reset timer m_AirTickTimer = DROWNING_TICKS; @@ -1382,8 +1382,8 @@ void cEntity::SetMass(double a_Mass) } else { - // Make sure that mass is not zero. 1g is the default because we - // have to choose a number. It's perfectly legal to have a mass + // Make sure that mass is not zero. 1g is the default because we + // have to choose a number. It's perfectly legal to have a mass // less than 1g as long as is NOT equal or less than zero. m_Mass = 0.001; } @@ -1469,7 +1469,7 @@ void cEntity::SetWidth(double a_Width) void cEntity::AddPosX(double a_AddPosX) { - m_Pos.x += a_AddPosX; + m_Pos.x += a_AddPosX; } @@ -1477,7 +1477,7 @@ void cEntity::AddPosX(double a_AddPosX) void cEntity::AddPosY(double a_AddPosY) { - m_Pos.y += a_AddPosY; + m_Pos.y += a_AddPosY; } @@ -1485,7 +1485,7 @@ void cEntity::AddPosY(double a_AddPosY) void cEntity::AddPosZ(double a_AddPosZ) { - m_Pos.z += a_AddPosZ; + m_Pos.z += a_AddPosZ; } @@ -1495,7 +1495,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; } @@ -1505,7 +1505,7 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed { m_Speed.x += a_AddSpeedX; m_Speed.y += a_AddSpeedY; - m_Speed.z += a_AddSpeedZ; + m_Speed.z += a_AddSpeedZ; WrapSpeed(); } @@ -1515,7 +1515,7 @@ void cEntity::AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeed void cEntity::AddSpeedX(double a_AddSpeedX) { - m_Speed.x += a_AddSpeedX; + m_Speed.x += a_AddSpeedX; WrapSpeed(); } @@ -1525,7 +1525,7 @@ void cEntity::AddSpeedX(double a_AddSpeedX) void cEntity::AddSpeedY(double a_AddSpeedY) { - m_Speed.y += a_AddSpeedY; + m_Speed.y += a_AddSpeedY; WrapSpeed(); } @@ -1535,7 +1535,7 @@ void cEntity::AddSpeedY(double a_AddSpeedY) void cEntity::AddSpeedZ(double a_AddSpeedZ) { - m_Speed.z += a_AddSpeedZ; + m_Speed.z += a_AddSpeedZ; WrapSpeed(); } @@ -1590,7 +1590,7 @@ Vector3d cEntity::GetLookVector(void) const // Set position void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) { - m_Pos.Set(a_PosX, a_PosY, a_PosZ); + m_Pos.Set(a_PosX, a_PosY, a_PosZ); } @@ -1599,7 +1599,7 @@ void cEntity::SetPosition(double a_PosX, double a_PosY, double a_PosZ) void cEntity::SetPosX(double a_PosX) { - m_Pos.x = a_PosX; + m_Pos.x = a_PosX; } @@ -1608,7 +1608,7 @@ void cEntity::SetPosX(double a_PosX) void cEntity::SetPosY(double a_PosY) { - m_Pos.y = a_PosY; + m_Pos.y = a_PosY; } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 011293233..7abe5db37 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -428,7 +428,7 @@ public: virtual void OnRightClicked(cPlayer &) {}; /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) { UNUSED(a_Drops); UNUSED(a_Killer); diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index 1e60f091c..798f844ce 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -99,7 +99,7 @@ public: protected: cItem m_Content; - int m_Height; + int m_Height; } ; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c4f9c59ab..7d9f6d67f 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -340,7 +340,7 @@ float cPlayer::GetXpPercentage() short int currentLevel = CalcLevelFromXp(m_CurrentXp); short int currentLevel_XpBase = XpForLevel(currentLevel); - return (float)(m_CurrentXp - currentLevel_XpBase) / + return (float)(m_CurrentXp - currentLevel_XpBase) / (float)(XpForLevel(1+currentLevel) - currentLevel_XpBase); } @@ -392,7 +392,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta) m_LifetimeTotalXp += a_Xp_delta; } - LOGD("Player \"%s\" gained/lost %d experience, total is now: %d", + LOGD("Player \"%s\" gained/lost %d experience, total is now: %d", GetName().c_str(), a_Xp_delta, m_CurrentXp); // Set experience to be updated @@ -1278,7 +1278,7 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const // TODO: Add a slight random change (+-0.0075 in each direction) return res * a_SpeedCoeff; -} +} @@ -1311,7 +1311,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos ) { // When attached to an entity, the client sends position packets with weird coords: // Y = -999 and X, Z = attempting to create speed, usually up to 0.03 - // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while + // We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while // the client may still send more of these nonsensical packets. if (m_AttachedTo != NULL) { @@ -1889,7 +1889,7 @@ bool cPlayer::SaveToDisk() { LOGWARNING("Error writing player \"%s\" to file \"%s\" - cannot save data. Player will lose their progress. ", GetName().c_str(), SourceFile.c_str() - ); + ); return false; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 171e9541b..0eef3e6e1 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -198,7 +198,7 @@ public: // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); - /** Forces the player to move in the given direction. + /** Forces the player to move in the given direction. @deprecated Use SetSpeed instead. */ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export @@ -430,7 +430,7 @@ protected: AString m_LoadedWorldName; /** Xp Level stuff */ - enum + enum { XP_TO_LEVEL15 = 255, XP_PER_LEVEL_TO15 = 17, diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 7b045de76..e6b05714e 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -52,7 +52,7 @@ public: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace); /// Called by the physics blocktracer when the entity hits another entity - virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) + virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { UNUSED(a_EntityHit); UNUSED(a_HitPos); @@ -89,7 +89,7 @@ public: protected: - /** A structure that stores the Entity ID and Playername of the projectile's creator + /** 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 diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index 8edc2800b..b306b1ee5 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -186,7 +186,7 @@ public: // Accessors used by cChunkGenerator::Generator descendants: inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; } inline cChunkDef::BlockTypes & GetBlockTypes (void) { return *((cChunkDef::BlockTypes *)m_BlockArea.GetBlockTypes()); } - // CANNOT, different compression! + // CANNOT, different compression! // inline cChunkDef::BlockNibbles & GetBlockMetas (void) { return *((cChunkDef::BlockNibbles *)m_BlockArea.GetBlockMetas()); } inline BlockNibbleBytes & GetBlockMetasUncompressed(void) { return *((BlockNibbleBytes *)m_BlockArea.GetBlockMetas()); } inline cChunkDef::HeightMap & GetHeightMap (void) { return m_HeightMap; } diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 160d095ed..faf2ac243 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -68,7 +68,7 @@ void cCompoGenDebugBiomes::ComposeTerrain(cChunkDesc & a_ChunkDesc) static BLOCKTYPE Blocks[] = { E_BLOCK_STONE, - E_BLOCK_COBBLESTONE, + E_BLOCK_COBBLESTONE, E_BLOCK_LOG, E_BLOCK_PLANKS, E_BLOCK_SANDSTONE, @@ -563,7 +563,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) { //* FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = - m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, 0, BaseZ + INTERPOL_Z * z) / 256; //*/ diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 167fbab37..09921abb0 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -234,7 +234,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile) { if (CacheSize < 4) { - LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", + LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", CacheSize, 4 ); CacheSize = 4; @@ -252,7 +252,7 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile) void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) { bool CacheOffByDefault = false; - m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault); + m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault); // Add a cache, if requested: int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64); @@ -260,7 +260,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) { if (CacheSize < 4) { - LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", + LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", CacheSize, 4 ); CacheSize = 4; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index dd1ab045d..13871bbd8 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -214,7 +214,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc) // Generate small foliage (1-block): // TODO: Update heightmap with 1-block-tall foliage - for (int z = 0; z < cChunkDef::Width; z++) + for (int z = 0; z < cChunkDef::Width; z++) { int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z; const float zz = (float)BlockZ; @@ -678,7 +678,7 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI AString HeightDistribution = a_IniFile.GetValueSet(SectionName, "HeightDistribution", DefaultHeightDistribution); if (!m_HeightDistribution.SetDefString(HeightDistribution) || (m_HeightDistribution.GetSum() <= 0)) { - LOGWARNING("[%sSprings]: HeightDistribution is invalid, using the default of \"%s\".", + LOGWARNING("[%sSprings]: HeightDistribution is invalid, using the default of \"%s\".", (a_Fluid == E_BLOCK_WATER) ? "Water" : "Lava", DefaultHeightDistribution.c_str() ); diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 537e30a31..b02e06951 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -267,7 +267,7 @@ float cHeiGenClassic::GetNoise(float x, float y) void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) { - for (int z = 0; z < cChunkDef::Width; z++) + for (int z = 0; z < cChunkDef::Width; z++) { const float zz = (float)(a_ChunkZ * cChunkDef::Width + z); for (int x = 0; x < cChunkDef::Width; x++) diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index fe1005dba..ae4b6e36c 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -1,7 +1,7 @@ // PieceGenerator.cpp -// Implements the cBFSPieceGenerator class and cDFSPieceGenerator class +// Implements the cBFSPieceGenerator class and cDFSPieceGenerator class // representing base classes for generating structures composed of individual "pieces" #include "Globals.h" diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index fd8576706..f06029280 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -1,7 +1,7 @@ // PieceGenerator.h -// Declares the cBFSPieceGenerator class and cDFSPieceGenerator class +// Declares the cBFSPieceGenerator class and cDFSPieceGenerator class // representing base classes for generating structures composed of individual "pieces" /* @@ -251,7 +251,7 @@ protected: const cPiece::cConnector & a_ExistingConnector, // The existing connector const Vector3i & a_ToPos, // The position on which the new connector should be placed const cPiece & a_Piece, // The new piece - const cPiece::cConnector & a_NewConnector, // The connector of the new piece + const cPiece::cConnector & a_NewConnector, // The connector of the new piece int a_NumCCWRotations, // Number of rotations for the new piece to align the connector const cPlacedPieces & a_OutPieces // All the already-placed pieces to check ); diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 7d876909a..6da3c3d10 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -181,7 +181,7 @@ void cPrefab::AddRotatedBlockAreas(void) m_BlockArea[2].CopyFrom(m_BlockArea[0]); m_BlockArea[2].MirrorXY(); m_BlockArea[2].MirrorYZ(); - } + } // 3 CCW rotations = 1 CW rotation: if ((m_AllowedRotations & 0x04) != 0) diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 8b4e4b4ef..eb905e78e 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -183,7 +183,7 @@ protected: bool m_MoveToGround; - // cPiece overrides: + // cPiece overrides: virtual cConnectors GetConnectors(void) const override; virtual Vector3i GetSize(void) const override; virtual cCuboid GetHitBox(void) const override; diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 2e41243d6..5deded17d 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -151,7 +151,7 @@ void cStructGenTrees::GenerateSingleTree( sSetBlockVector TreeLogs, TreeOther; GetTreeImageByBiome( a_ChunkX * cChunkDef::Width + x, Height + 1, a_ChunkZ * cChunkDef::Width + z, - m_Noise, a_Seq, + m_Noise, a_Seq, a_ChunkDesc.GetBiome(x, z), TreeLogs, TreeOther ); @@ -181,7 +181,7 @@ void cStructGenTrees::GenerateSingleTree( } ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeOther, a_OutsideOther); - ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs); + ApplyTreeImage(a_ChunkX, a_ChunkZ, a_ChunkDesc, TreeLogs, a_OutsideLogs); } @@ -500,7 +500,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a continue; } int IdxYZ = BubbleX + IdxY + (BubbleZ + z) * 16; - for (int x = -BubbleR; x <= BubbleR; x++) + for (int x = -BubbleR; x <= BubbleR; x++) { if (x * x + DistYZ < RSquared) { @@ -511,10 +511,10 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a } // for y } // for i - bubbles - // Turn air in the bottom half into liquid: + // Turn air in the bottom half into liquid: for (int y = 0; y < 4; y++) { - for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) + for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) { if (BlockTypes[x + z * 16 + y * 16 * 16] == E_BLOCK_AIR) { @@ -573,8 +573,8 @@ void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc) // Interpolate the lowest floor: for (int z = 0; z <= 16 / INTERPOL_Z; z++) for (int x = 0; x <= 16 / INTERPOL_X; x++) { - FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = - m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) * + FloorLo[INTERPOL_X * x + 17 * INTERPOL_Z * z] = + m_Noise1.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) * m_Noise2.IntNoise3DInt(BaseX + INTERPOL_X * x, BaseY, BaseZ + INTERPOL_Z * z) / 256; } // for x, z - FloorLo[] diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 7478be69b..eac086de6 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -83,7 +83,7 @@ static const sCoords BigO4[] = // Part of Big Jungle tree -typedef struct +typedef struct { const sCoords * Coords; size_t Count; @@ -203,7 +203,7 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No { GetAppleBushImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); } - else + else { GetJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); } @@ -598,11 +598,11 @@ void GetPineTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise } int h = a_BlockY + TrunkHeight + 2; - // Top layer - just a single leaves block: + // Top layer - just a single leaves block: a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER)); h--; - // One more layer is above the trunk, push the central leaves: + // One more layer is above the trunk, push the central leaves: a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER)); // Layers expanding in size, then collapsing again: diff --git a/src/HTTPServer/HTTPMessage.cpp b/src/HTTPServer/HTTPMessage.cpp index f7e8f5f30..4226352e9 100644 --- a/src/HTTPServer/HTTPMessage.cpp +++ b/src/HTTPServer/HTTPMessage.cpp @@ -139,7 +139,7 @@ AString cHTTPRequest::GetBareURL(void) const size_t cHTTPRequest::ParseRequestLine(const char * a_Data, size_t a_Size) -{ +{ m_IncomingHeaderData.append(a_Data, a_Size); size_t IdxEnd = m_IncomingHeaderData.size(); diff --git a/src/Items/ItemBed.h b/src/Items/ItemBed.h index f23d69731..94a14cf16 100644 --- a/src/Items/ItemBed.h +++ b/src/Items/ItemBed.h @@ -26,7 +26,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemBrewingStand.h b/src/Items/ItemBrewingStand.h index d5eefb855..7be57763c 100644 --- a/src/Items/ItemBrewingStand.h +++ b/src/Items/ItemBrewingStand.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemCake.h b/src/Items/ItemCake.h index 48e23ed59..d1cb091b6 100644 --- a/src/Items/ItemCake.h +++ b/src/Items/ItemCake.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemCauldron.h b/src/Items/ItemCauldron.h index 07ae12660..9617c30ef 100644 --- a/src/Items/ItemCauldron.h +++ b/src/Items/ItemCauldron.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemComparator.h b/src/Items/ItemComparator.h index 60d9c3648..fc843c186 100644 --- a/src/Items/ItemComparator.h +++ b/src/Items/ItemComparator.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index f3677c28c..c1b439024 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 @@ -33,8 +33,8 @@ public: a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR; cChunkInterface ChunkInterface(a_World->GetChunkMap()); bool Meta = BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta( - ChunkInterface, a_Player, - a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, + ChunkInterface, a_Player, + a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 435d8ccf4..0c07cd422 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -210,7 +210,7 @@ public: if (FishType <= 1) // Clownfish has a 2% chance of spawning { Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH)); - } + } else if (FishType <= 12) // Pufferfish has a 13% chance of spawning { Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH)); diff --git a/src/Items/ItemFlowerPot.h b/src/Items/ItemFlowerPot.h index 60bf87985..320dce997 100644 --- a/src/Items/ItemFlowerPot.h +++ b/src/Items/ItemFlowerPot.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index c261ce0e8..3e02a43fa 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -458,7 +458,7 @@ char cItemHandler::GetMaxStackSize(void) bool cItemHandler::IsTool() { // TODO: Rewrite this to list all tools specifically - return + return (m_ItemType >= 256 && m_ItemType <= 259) || (m_ItemType == 261) || (m_ItemType >= 267 && m_ItemType <= 279) @@ -525,7 +525,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) bool cItemHandler::GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 ) @@ -542,7 +542,7 @@ bool cItemHandler::GetPlacementBlockTypeMeta( cChunkInterface ChunkInterface(a_World->GetChunkMap()); return BlockH->GetPlacementBlockTypeMeta( ChunkInterface, a_Player, - a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, + a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta ); diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index b33671c2d..3ea04d1cb 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -28,7 +28,7 @@ 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); /** Called when the client sends the SHOOT status in the lclk packet */ - virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) + virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) { UNUSED(a_BlockX); UNUSED(a_BlockY); @@ -97,7 +97,7 @@ public: */ virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 ); diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h index 0ed6e5e0e..f48126dc5 100644 --- a/src/Items/ItemLeaves.h +++ b/src/Items/ItemLeaves.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemMobHead.h b/src/Items/ItemMobHead.h index 5ae040282..4c36fe8d8 100644 --- a/src/Items/ItemMobHead.h +++ b/src/Items/ItemMobHead.h @@ -26,7 +26,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemNetherWart.h b/src/Items/ItemNetherWart.h index a6a9a286a..10a0864b5 100644 --- a/src/Items/ItemNetherWart.h +++ b/src/Items/ItemNetherWart.h @@ -25,7 +25,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index 33e386b03..a2289239c 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -22,7 +22,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemRedstoneRepeater.h b/src/Items/ItemRedstoneRepeater.h index c5fb5d566..13a797d00 100644 --- a/src/Items/ItemRedstoneRepeater.h +++ b/src/Items/ItemRedstoneRepeater.h @@ -24,7 +24,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemSapling.h b/src/Items/ItemSapling.h index 61b1a32be..dbcb12be5 100644 --- a/src/Items/ItemSapling.h +++ b/src/Items/ItemSapling.h @@ -20,7 +20,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 53f5d51c3..4c9e82ae0 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -30,7 +30,7 @@ public: case E_ITEM_CARROT: case E_ITEM_POTATO: return true; default: return false; - } + } } virtual FoodInfo GetFoodInfo(void) override @@ -45,7 +45,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 60cf0f5f8..235a4fa93 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -27,7 +27,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Items/ItemSugarcane.h b/src/Items/ItemSugarcane.h index e891cc367..dd2e2ece3 100644 --- a/src/Items/ItemSugarcane.h +++ b/src/Items/ItemSugarcane.h @@ -23,7 +23,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + 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 diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index de881f4eb..5f5b1853d 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -42,7 +42,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt) MoveToPosition(m_Target->GetPosition()); } } -} +} diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 9e53284b3..df2572976 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -353,13 +353,13 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) // If enemy passive we ignore checks for player visibility InStateIdle(a_Dt); break; - } + } case CHASING: { // If we do not see a player anymore skip chasing action InStateChasing(a_Dt); break; - } + } case ESCAPING: { InStateEscaping(a_Dt); @@ -588,7 +588,7 @@ void cMonster::CheckEventSeePlayer(void) void cMonster::CheckEventLostPlayer(void) -{ +{ if (m_Target != NULL) { if ((m_Target->GetPosition() - GetPosition()).Length() > m_SightDistance) diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 96e73b45b..750040468 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -233,7 +233,7 @@ protected: AString m_SoundHurt; AString m_SoundDeath; - float m_AttackRate; + float m_AttackRate; int m_AttackDamage; int m_AttackRange; float m_AttackInterval; @@ -250,13 +250,13 @@ protected: bool m_BurnsInDaylight; /** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/ - void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); + void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); /** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/ - void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0); + void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0); /** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/ - void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel); + void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel); /** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/ void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel); diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index d183a338f..1cdac7c74 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -55,7 +55,7 @@ void cVillager::Tick(float a_Dt, cChunk & a_Chunk) { switch (m_Type) { - case vtFarmer: + case vtFarmer: { HandleFarmerPlaceCrops(); } diff --git a/src/OSSupport/CriticalSection.cpp b/src/OSSupport/CriticalSection.cpp index 6d4afce55..5dfc8b5f9 100644 --- a/src/OSSupport/CriticalSection.cpp +++ b/src/OSSupport/CriticalSection.cpp @@ -108,7 +108,7 @@ bool cCriticalSection::IsLockedByCurrentThread(void) //////////////////////////////////////////////////////////////////////////////// // cCSLock -cCSLock::cCSLock(cCriticalSection * a_CS) +cCSLock::cCSLock(cCriticalSection * a_CS) : m_CS(a_CS) , m_IsLocked(false) { @@ -119,7 +119,7 @@ cCSLock::cCSLock(cCriticalSection * a_CS) -cCSLock::cCSLock(cCriticalSection & a_CS) +cCSLock::cCSLock(cCriticalSection & a_CS) : m_CS(&a_CS) , m_IsLocked(false) { diff --git a/src/OSSupport/CriticalSection.h b/src/OSSupport/CriticalSection.h index 73a71f5e1..c3c6e57f0 100644 --- a/src/OSSupport/CriticalSection.h +++ b/src/OSSupport/CriticalSection.h @@ -47,7 +47,7 @@ class cCSLock cCriticalSection * m_CS; // Unlike a cCriticalSection, this object should be used from a single thread, therefore access to m_IsLocked is not threadsafe - // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held, + // In Windows, it is an error to call cCriticalSection::Unlock() multiple times if the lock is not held, // therefore we need to check this value whether we are locked or not. bool m_IsLocked; diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index beb6a63f1..269f9db41 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -21,7 +21,7 @@ cQueueFuncs and is used as the default behavior. /// This empty struct allows for the callback functions to be inlined template -struct cQueueFuncs +struct cQueueFuncs { public: @@ -88,7 +88,7 @@ public: cCSLock Lock(m_CS); if (m_Contents.size() == 0) { - return false; + return false; } item = m_Contents.front(); m_Contents.pop_front(); diff --git a/src/OSSupport/Socket.cpp b/src/OSSupport/Socket.cpp index 56835b518..7d4d9e598 100644 --- a/src/OSSupport/Socket.cpp +++ b/src/OSSupport/Socket.cpp @@ -244,7 +244,7 @@ cSocket cSocket::AcceptIPv6(void) // Windows XP doesn't have inet_ntop, so we need to improvise. And MSVC has different headers than GCC #ifdef _MSC_VER // MSVC version - Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", + Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", from.sin6_addr.u.Word[0], from.sin6_addr.u.Word[1], from.sin6_addr.u.Word[2], @@ -256,7 +256,7 @@ cSocket cSocket::AcceptIPv6(void) ); #else // _MSC_VER // MinGW - Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", + Printf(SClient.m_IPString, "%x:%x:%x:%x:%x:%x:%x:%x", from.sin6_addr.s6_addr16[0], from.sin6_addr.s6_addr16[1], from.sin6_addr.s6_addr16[2], diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp index 001bc29cf..18924db2f 100644 --- a/src/Protocol/Authenticator.cpp +++ b/src/Protocol/Authenticator.cpp @@ -248,7 +248,7 @@ bool cAuthenticator::SecureGetFromAddress(const AString & a_CACerts, const AStri 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()); + LOGD("Trying to authenticate user %s", a_UserName.c_str()); // Create the GET request: AString ActualAddress = m_Address; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index 325218d88..e2960d0c3 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -398,7 +398,7 @@ void cProtocol125::SendEntityMetadata(const cEntity & a_Entity) else { WriteEntityMetadata(a_Entity); - } + } WriteByte(0x7f); Flush(); @@ -2110,7 +2110,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob) int Appearance = 0; Appearance = ((const cHorse &)a_Mob).GetHorseColor(); // Mask FF Appearance |= ((const cHorse &)a_Mob).GetHorseStyle() * 256; // Mask FF00, so multiply by 256 - WriteInt(Appearance); + WriteInt(Appearance); WriteByte(0x56); WriteInt(((const cHorse &)a_Mob).GetHorseArmour()); // Horshey armour diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index a92ae83da..8502702e8 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -382,7 +382,7 @@ void cProtocol132::SendUnloadChunk(int a_ChunkX, int a_ChunkZ) void cProtocol132::SendWholeInventory(const cWindow & a_Window) { - // 1.3.2 requires player inventory slots to be sent as SetSlot packets, + // 1.3.2 requires player inventory slots to be sent as SetSlot packets, // otherwise it sometimes fails to update the window // Send the entire window: diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 36d1f4af4..45cda944b 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1026,7 +1026,7 @@ void cProtocol172::SendExperienceOrb(const cExpOrb & a_ExpOrb) { ASSERT(m_State == 3); // In game mode? - cPacketizer Pkt(*this, 0x11); + cPacketizer Pkt(*this, 0x11); Pkt.WriteVarInt(a_ExpOrb.GetUniqueID()); Pkt.WriteInt((int) a_ExpOrb.GetPosX()); Pkt.WriteInt((int) a_ExpOrb.GetPosY()); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 29f4576cd..d3aae65fe 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -1,7 +1,7 @@ // ProtocolRecognizer.cpp -// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple +// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple // protocol versions and redirects everything to them #include "Globals.h" @@ -828,7 +828,7 @@ void cProtocolRecognizer::SendData(const char * a_Data, size_t a_Size) bool cProtocolRecognizer::TryRecognizeProtocol(void) { - // NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and + // NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and // MCS_PROTOCOL_VERSIONS macros in the header file, as well as PROTO_VERSION_LATEST macro // The first packet should be a Handshake, 0x02: @@ -1021,7 +1021,7 @@ void cProtocolRecognizer::SendLengthlessServerPing(void) case PROTO_VERSION_1_3_2: { // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29 - Printf(Reply, "%s%s%i%s%i", + Printf(Reply, "%s%s%i%s%i", Server->GetDescription().c_str(), cChatColor::Delimiter.c_str(), Server->GetNumPlayers(), diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 25c60a72e..6bfd73d74 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -1,7 +1,7 @@ // ProtocolRecognizer.h -// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple +// Interfaces to the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple // protocol versions and redirects everything to them diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index 884069b21..59ea51aa0 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -131,7 +131,7 @@ void cDelayedFluidSimulator::Simulate(float a_Dt) void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) -{ +{ void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData(); cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw; cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum]; diff --git a/src/Simulator/DelayedFluidSimulator.h b/src/Simulator/DelayedFluidSimulator.h index c81500741..fe59f6dd6 100644 --- a/src/Simulator/DelayedFluidSimulator.h +++ b/src/Simulator/DelayedFluidSimulator.h @@ -50,7 +50,7 @@ class cDelayedFluidSimulator : { typedef cFluidSimulator super; -public: +public: cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay); // cSimulator overrides: diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 1ad4f2654..9433a8c68 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -306,14 +306,14 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int // No need to check the coords for equality with the parent block, // it cannot catch fire anyway (because it's not an air block) - if (m_World.GetTickRandomNumber(MAX_CHANCE_FLAMMABILITY) > m_Flammability) + if (m_World.GetTickRandomNumber(MAX_CHANCE_FLAMMABILITY) > m_Flammability) { continue; } // Start the fire in the neighbor {x, y, z} /* - FLOG("FS: Trying to start fire at {%d, %d, %d}.", + FLOG("FS: Trying to start fire at {%d, %d, %d}.", x + a_Chunk->GetPosX() * cChunkDef::Width, y, z + a_Chunk->GetPosZ() * cChunkDef::Width ); */ diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index d8de19871..2c5c4b658 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -48,7 +48,7 @@ cFloodyFluidSimulator::cFloodyFluidSimulator( void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) { - FLOG("Simulating block {%d, %d, %d}: block %d, meta %d", + FLOG("Simulating block {%d, %d, %d}: block %d, meta %d", a_Chunk->GetPosX() * cChunkDef::Width + a_RelX, a_RelY, a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ, a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ), a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ) @@ -248,7 +248,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i { // Lava flowing into water, change to stone / cobblestone based on direction: BLOCKTYPE NewBlock = (a_NewMeta == 8) ? E_BLOCK_STONE : E_BLOCK_COBBLESTONE; - FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone", + FLOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone", a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str() ); @@ -264,7 +264,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i { // Water flowing into lava, change to cobblestone / obsidian based on dest block: BLOCKTYPE NewBlock = (BlockMeta == 0) ? E_BLOCK_OBSIDIAN : E_BLOCK_COBBLESTONE; - FLOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s", + 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->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0); @@ -296,8 +296,8 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i ChunkInterface, m_World, PluginInterface, - NULL, - BlockX, + NULL, + BlockX, a_RelY, BlockZ ); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 0d4815c00..6249e0cdd 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -59,7 +59,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, // Use that Chunk pointer to get a relative position int RelX = 0; - int RelZ = 0; + int RelZ = 0; BLOCKTYPE Block; NIBBLETYPE Meta; @@ -821,7 +821,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() void cIncrementalRedstoneSimulator::HandlePiston(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; @@ -1518,7 +1518,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsDirectlyPowered(int a_RelBlockX, in return true; } } - return false; + return false; } @@ -1616,7 +1616,7 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_Rel bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta) -{ +{ switch (a_Meta & 0x3) // We only want the 'direction' part of our metadata { // If the repeater is looking up or down (If parallel to the Z axis) @@ -1648,14 +1648,14 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB // Check if southern(down) neighbor is a powered on repeater who is facing us BLOCKTYPE Block = 0; if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) - { + { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3; if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked } // Check if northern(up) neighbor is a powered on repeater who is facing us if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) - { + { NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3; if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked } @@ -2082,7 +2082,7 @@ bool cIncrementalRedstoneSimulator::QueueRepeaterPowerChange(int a_RelBlockX, in } // Self not in list, add self to list - sRepeatersDelayList RC; + sRepeatersDelayList RC; RC.a_RelBlockPos = Vector3i(a_RelBlockX, a_RelBlockY, a_RelBlockZ); // Gets the top two bits (delay time), shifts them into the lower two bits, and adds one (meta 0 = 1 tick; 1 = 2 etc.) diff --git a/src/Simulator/NoopFluidSimulator.h b/src/Simulator/NoopFluidSimulator.h index 9113aec3c..9fe2f9040 100644 --- a/src/Simulator/NoopFluidSimulator.h +++ b/src/Simulator/NoopFluidSimulator.h @@ -27,7 +27,7 @@ public: } // cSimulator overrides: - virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override + virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { UNUSED(a_BlockX); UNUSED(a_BlockY); diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h index e5338ad44..4301b8aae 100644 --- a/src/Simulator/NoopRedstoneSimulator.h +++ b/src/Simulator/NoopRedstoneSimulator.h @@ -21,7 +21,7 @@ public: // ~cRedstoneNoopSimulator(); virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used - virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override + virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override { UNUSED(a_Dt); UNUSED(a_ChunkX); diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h index 6e64aa425..1262f2792 100644 --- a/src/Simulator/SandSimulator.h +++ b/src/Simulator/SandSimulator.h @@ -37,7 +37,7 @@ public: based on the block currently present in the world at the dest specified coords */ static void FinishFalling( - cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, + cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_FallingBlockType, NIBBLETYPE a_FallingBlockMeta ); diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index a2e2a5742..171eba91c 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -26,7 +26,7 @@ public: /// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available virtual void SimulateChunk(float a_Dt, int a_ChunkX, - int a_ChunkZ, cChunk * a_Chunk) + int a_ChunkZ, cChunk * a_Chunk) { UNUSED(a_Dt); UNUSED(a_ChunkX); diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp index 191770273..484cac334 100644 --- a/src/Simulator/VaporizeFluidSimulator.cpp +++ b/src/Simulator/VaporizeFluidSimulator.cpp @@ -27,7 +27,7 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, return; } int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width; - int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; + int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ); if ( (BlockType == m_FluidBlock) || diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 0a9502491..21b6ed0c8 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -36,8 +36,8 @@ cSlotArea::cSlotArea(int a_NumSlots, cWindow & a_ParentWindow) : void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { /* - LOGD("Slot area with %d slots clicked at slot number %d, clicked item %s, slot item %s", - GetNumSlots(), a_SlotNum, + LOGD("Slot area with %d slots clicked at slot number %d, clicked item %s, slot item %s", + GetNumSlots(), a_SlotNum, ItemToFullString(a_ClickedItem).c_str(), ItemToFullString(*GetSlot(a_SlotNum, a_Player)).c_str() ); @@ -1280,7 +1280,7 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio } case caLeftClick: - { + { // Left-clicked if (DraggingItem.IsEmpty()) { diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index b550068b1..6606beda2 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -164,7 +164,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const void cWindow::Clicked( - cPlayer & a_Player, + cPlayer & a_Player, int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem ) diff --git a/src/UI/Window.h b/src/UI/Window.h index b170a9d78..1872b2c20 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -36,12 +36,12 @@ typedef std::vector cSlotAreas; // tolua_begin -/** +/** Represents a UI window. Each window has a list of players that are currently using it When there's no player using a window, it is destroyed. -A window consists of several areas of slots with similar functionality - for example the crafting grid area, or +A window consists of several areas of slots with similar functionality - for example the crafting grid area, or the inventory area. Each area knows what its slots are (GetSlot() function) and can handle mouse clicks. The window acts only as a top-level container for those areas, redirecting the click events to the correct areas. Inventory painting, introduced in 1.5, is handled by the window, too @@ -109,7 +109,7 @@ public: /// Handles a click event from a player void Clicked( - cPlayer & a_Player, int a_WindowID, + cPlayer & a_Player, int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem ); diff --git a/src/UI/WindowOwner.h b/src/UI/WindowOwner.h index e3c73edc4..7a7941e37 100644 --- a/src/UI/WindowOwner.h +++ b/src/UI/WindowOwner.h @@ -6,7 +6,7 @@ #include "Window.h" /* -Being a descendant of cWindowOwner means that the class can own one window. That window can be +Being a descendant of cWindowOwner means that the class can own one window. That window can be queried, opened by other players, closed by players and finally destroyed. Also, a cWindowOwner can be queried for the block coords where the window is displayed. That will be used for entities / players in motion to close their windows when they get too far away from the window "source". diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 8e7247aab..c6294b99c 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -10,7 +10,7 @@ -// The number of NBT tags that are reserved when an NBT parsing is started. +// The number of NBT tags that are reserved when an NBT parsing is started. // You can override this by using a cmdline define #ifndef NBT_RESERVE_SIZE #define NBT_RESERVE_SIZE 200 @@ -69,7 +69,7 @@ bool cParsedNBT::Parse(void) m_Pos = 1; - RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength)); + RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength)); RETURN_FALSE_IF_FALSE(ReadCompound()); return true; diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index fe28005ac..7aa83fc24 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -5,11 +5,11 @@ /* The fast parser parses the data into a vector of cFastNBTTag structures. These structures describe the NBT tree, -but themselves are allocated in a vector, thus minimizing reallocation. +but themselves are allocated in a vector, thus minimizing reallocation. The structures have a minimal constructor, setting all member "pointers" to "invalid". The fast writer doesn't need a NBT tree structure built beforehand, it is commanded to open, append and close tags -(just like XML); it keeps the internal tag stack and reports errors in usage. +(just like XML); it keeps the internal tag stack and reports errors in usage. It directly outputs a string containing the serialized NBT data. */ @@ -173,7 +173,7 @@ public: } /** Returns the value stored in a Byte tag. Not valid for any other tag type. */ - inline unsigned char GetByte(int a_Tag) const + inline unsigned char GetByte(int a_Tag) const { ASSERT(m_Tags[(size_t)a_Tag].m_Type == TAG_Byte); return (unsigned char)(m_Data[(size_t)m_Tags[(size_t)a_Tag].m_DataStart]); diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp index 5a2be8867..ecb600483 100644 --- a/src/WorldStorage/FireworksSerializer.cpp +++ b/src/WorldStorage/FireworksSerializer.cpp @@ -98,7 +98,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB // Divide by four as data length returned in bytes size_t DataLength = a_NBT.GetDataLength(explosiontag); // round to the next highest multiple of four - DataLength -= DataLength % 4; + DataLength -= DataLength % 4; if (DataLength == 0) { continue; @@ -114,7 +114,7 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB { size_t DataLength = a_NBT.GetDataLength(explosiontag) / 4; // round to the next highest multiple of four - DataLength -= DataLength % 4; + DataLength -= DataLength % 4; if (DataLength == 0) { continue; diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 388ad0332..b4048b097 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -56,7 +56,7 @@ thus making skylight visible in Minutor's Lighting mode */ // #define DEBUG_SKYLIGHT -/** Maximum number of MCA files that are cached in memory. +/** Maximum number of MCA files that are cached in memory. Since only the header is actually in the memory, this number can be high, but still, each file means an OS FS handle. */ #define MAX_MCA_FILES 32 @@ -393,7 +393,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT m_World->SetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, - BlockTypes, MetaData, + BlockTypes, MetaData, IsLightValid ? BlockLight : NULL, IsLightValid ? SkyLight : NULL, NULL, Biomes, @@ -449,7 +449,7 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ const char * BlockLight = (const char *)(Serializer.m_BlockSkyLight); #else const char * BlockLight = (const char *)(Serializer.m_BlockLight); - #endif + #endif const char * BlockSkyLight = (const char *)(Serializer.m_BlockSkyLight); for (int Y = 0; Y < 16; Y++) { @@ -463,7 +463,7 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ } a_Writer.EndList(); // "Sections" - // Store the information that the lighting is valid. + // Store the information that the lighting is valid. // For compatibility reason, the default is "invalid" (missing) - this means older data is re-lighted upon loading. if (Serializer.IsLightValid()) { @@ -2363,8 +2363,8 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N return; } int OwnerIdx = a_NBT.FindChildByName(a_TagIdx, "Owner"); - if (OwnerIdx > 0) - { + if (OwnerIdx > 0) + { AString OwnerName = a_NBT.GetString(OwnerIdx); if (OwnerName != "") { diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 3b08c5ac5..ff43b6905 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -603,7 +603,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { - LOGERROR("Error %d decompressing data for chunk [%d, %d]", + LOGERROR("Error %d decompressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -627,7 +627,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() char ConvertedData[cChunkDef::BlockDataSize]; int Index = 0; unsigned int InChunkOffset = 0; - for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) + for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) { for( int y = 0; y < 128; ++y ) { @@ -683,7 +683,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2() int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor); if (errorcode != Z_OK) { - LOGERROR("Error %d compressing data for chunk [%d, %d]", + LOGERROR("Error %d compressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -747,7 +747,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, (size_t)UncompressedSize); if (errorcode != Z_OK) { - LOGERROR("Error %d decompressing data for chunk [%d, %d]", + LOGERROR("Error %d decompressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -819,7 +819,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3() int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor); if (errorcode != Z_OK) { - LOGERROR("Error %d compressing data for chunk [%d, %d]", + LOGERROR("Error %d compressing data for chunk [%d, %d]", errorcode, Header->m_ChunkX, Header->m_ChunkZ ); @@ -863,7 +863,7 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int a_Uncompre int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, (size_t)a_UncompressedSize); if (errorcode != Z_OK) { - LOGERROR("Error %d decompressing data for chunk [%d, %d]", + LOGERROR("Error %d decompressing data for chunk [%d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ ); diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index b6d572f3e..155aa6b14 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -202,7 +202,7 @@ void cWorldStorage::InitSchemas(int a_StorageCompressionFactor) } // for itr - m_Schemas[] // Unknown schema selected, let the admin know: - LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:", + LOGWARNING("Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:", m_StorageSchemaName.c_str(), m_SaveSchema->GetName().c_str() ); for (cWSSchemaList::iterator itr = m_Schemas.begin(); itr != m_Schemas.end(); ++itr) diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 1204b4310..bf764a539 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -95,7 +95,7 @@ protected: bool operator==(const sChunkLoad other) const { - return this->m_ChunkX == other.m_ChunkX && + return this->m_ChunkX == other.m_ChunkX && this->m_ChunkY == other.m_ChunkY && this->m_ChunkZ == other.m_ChunkZ; } @@ -103,7 +103,7 @@ protected: struct FuncTable { static void Delete(sChunkLoad) {}; - static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) + static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) { a_orig.m_Generate |= a_new.m_Generate; }; From 5c0789e15e56d0342af57c4e8d821dfba46c9227 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 14:08:21 -0700 Subject: [PATCH 263/280] Player.cpp: Added Wither death message --- src/Entities/Player.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7d9f6d67f..b11fd9440 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -905,6 +905,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) 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 dtWithering: DamageText = "is a husk of their former selves" 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; From 488ecb6912dfd279509de2bec79b2f461c01056a Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 14:08:54 -0700 Subject: [PATCH 264/280] Player.cpp: Fixed compile error --- 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 b11fd9440..a1dfed39c 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -905,7 +905,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) 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 dtWithering: DamageText = "is a husk of their former selves" + case dtWithering: DamageText = "is a husk of their former selves"; 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; From d0cc9aedb3e63d39324c52b6385406f362ab41b7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:59:02 +0200 Subject: [PATCH 265/280] More trailing whitespace fixes. --- src/Blocks/BlockLadder.h | 6 +++--- src/Entities/Entity.cpp | 4 ++-- src/Entities/Minecart.cpp | 8 ++++---- src/Entities/Pickup.cpp | 2 +- src/Entities/Player.cpp | 2 +- src/Items/ItemBucket.h | 8 ++++---- src/Items/ItemHandler.h | 2 +- src/Items/ItemSeeds.h | 2 +- src/Mobs/Creeper.cpp | 2 +- src/Mobs/Horse.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.cpp | 8 ++++---- src/UI/Window.cpp | 2 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h index 2c41083e7..72acced41 100644 --- a/src/Blocks/BlockLadder.h +++ b/src/Blocks/BlockLadder.h @@ -12,17 +12,17 @@ class cBlockLadderHandler : public cClearMetaOnDrop > { - typedef cClearMetaOnDrop > super; + typedef cClearMetaOnDrop > super; public: cBlockLadderHandler(BLOCKTYPE a_BlockType) : super(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_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 diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 0ff3ff102..7d130aa47 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -640,7 +640,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) if ((BlockY >= cChunkDef::Height) || (BlockY < 0)) { - // Outside of the world + // Outside of the world AddSpeedY(m_Gravity * a_Dt); AddPosition(GetSpeed() * a_Dt); return; @@ -858,7 +858,7 @@ void cEntity::TickBurning(cChunk & a_Chunk) if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT)) { m_TicksLeftBurning = 0; - } + } } // Do the burning damage: diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 6502ae45a..03850c8a7 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -493,7 +493,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) SetSpeedY(-GetSpeedX()); } break; - } + } case E_META_RAIL_ASCEND_XP: // ASCEND WEST { SetYaw(180); @@ -513,7 +513,7 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta) } } break; - } + } case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH { SetYaw(270); @@ -787,7 +787,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta) } } break; - } + } case E_META_RAIL_CURVED_ZM_XM: case E_META_RAIL_CURVED_ZM_XP: case E_META_RAIL_CURVED_ZP_XM: @@ -883,7 +883,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta) } } return true; - } + } case E_META_RAIL_CURVED_ZM_XM: case E_META_RAIL_CURVED_ZM_XP: case E_META_RAIL_CURVED_ZP_XM: diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index ab0f856dd..18df1a210 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -143,7 +143,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) m_bCollected = true; m_Timer = 0; // We have to reset the timer. m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick. - if (m_Timer > 500.f) + if (m_Timer > 500.f) { Destroy(true); return; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index a1dfed39c..6e7623f4a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -497,7 +497,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround) // Fall particles GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */); - } + } m_LastGroundHeight = (float)GetPosY(); } diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 4cdfab0fe..6d7926fa4 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -94,7 +94,7 @@ 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 != BLOCK_FACE_NONE) { return false; @@ -209,14 +209,14 @@ public: } 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()); - Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); + 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 // Use this to judge whether the position is valid @@ -227,6 +227,6 @@ public: return true; } - return false; + return false; } }; diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 3ea04d1cb..c7362c5f4 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -91,7 +91,7 @@ public: /** Can the anvil repair this item, when a_Item is the second input? */ virtual bool CanRepairWithRawMaterial(short a_ItemType); - /** Called before a block is placed into a world. + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. */ diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 4c9e82ae0..54a1183d7 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -40,7 +40,7 @@ public: case E_ITEM_CARROT: return FoodInfo(4, 4.8); case E_ITEM_POTATO: return FoodInfo(1, 0.6); default: return FoodInfo(0, 0); - } + } } virtual bool GetPlacementBlockTypeMeta( diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 495f1dd25..02718edf8 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -37,7 +37,7 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) { if (m_bIsBlowing) { - m_ExplodingTimer += 1; + m_ExplodingTimer += 1; } if (m_ExplodingTimer == 30) diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index 9d130301f..67a09d4ab 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -63,7 +63,7 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) m_Attachee->Detach(); m_bIsRearing = true; } - } + } else { m_bIsTame = true; diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 6249e0cdd..eb12c08e0 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -281,7 +281,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int if (ShouldUpdateSimulateOnceBlocks) { switch (dataitr->Data) - { + { case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_COMMAND_BLOCK: HandleCommandBlock(dataitr->x, dataitr->y, dataitr->z); break; case E_BLOCK_NOTE_BLOCK: HandleNoteBlock(dataitr->x, dataitr->y, dataitr->z); break; @@ -392,7 +392,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R if (a_MyState == E_BLOCK_REDSTONE_TORCH_ON) { - // Check if the block the torch is on is powered + // 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 @@ -448,7 +448,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R } else { - // Check if the block the torch is on is powered + // 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 @@ -803,7 +803,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeaterDelays() } 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); } diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 6606beda2..2558d15b8 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -145,7 +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) { diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 3f79a6572..e68903b26 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -630,7 +630,7 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) { ASSERT(!"Unsaved projectile entity!"); } - } // switch (ProjectileKind) + } // switch (ProjectileKind) if (!a_Projectile->GetCreatorName().empty()) { From c03161f75d22a7965aea20fb9843ae580a07079a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 23:15:53 +0200 Subject: [PATCH 266/280] Fixed tabs used for alignment. --- src/Blocks/BlockSnow.h | 4 +- src/Entities/Entity.cpp | 2 +- src/Entities/Entity.h | 2 +- src/Entities/ExpOrb.cpp | 4 +- src/Entities/HangingEntity.cpp | 2 +- src/Entities/ItemFrame.cpp | 2 +- src/Entities/Pickup.cpp | 2 +- src/Entities/Pickup.h | 2 +- src/Entities/Player.cpp | 8 +-- src/Entities/Player.h | 26 +++++----- src/Generating/Caves.cpp | 12 ++--- src/Generating/ChunkGenerator.cpp | 6 +-- src/Generating/FinishGen.h | 2 +- src/Generating/Ravines.cpp | 22 ++++---- src/Generating/VillageGen.cpp | 2 +- src/Items/ItemFishingRod.h | 2 +- src/Items/ItemHandler.cpp | 14 +++--- src/Mobs/Monster.cpp | 2 +- src/OSSupport/Semaphore.cpp | 50 ++++++++++++------- src/OSSupport/Sleep.cpp | 2 +- src/OSSupport/Thread.cpp | 2 +- src/Protocol/Protocol125.cpp | 18 +++---- src/Protocol/Protocol17x.cpp | 7 +-- src/Simulator/DelayedFluidSimulator.h | 2 +- src/Simulator/FluidSimulator.cpp | 2 +- .../IncrementalRedstoneSimulator.cpp | 2 +- src/Simulator/IncrementalRedstoneSimulator.h | 2 +- src/UI/SlotArea.h | 4 +- src/WorldStorage/MapSerializer.h | 7 ++- 29 files changed, 115 insertions(+), 99 deletions(-) diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h index 27fc17e7f..977f19a16 100644 --- a/src/Blocks/BlockSnow.h +++ b/src/Blocks/BlockSnow.h @@ -33,8 +33,8 @@ public: if ((BlockBeforePlacement == E_BLOCK_SNOW) && (MetaBeforePlacement < 7)) { // Only increment if: - // A snow block was already there (not first time placement) AND - // Height is smaller than 7, the maximum possible height + // - A snow block was already there (not first time placement) AND + // - Height is smaller than 7, the maximum possible height MetaBeforePlacement++; } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 7d130aa47..28817428f 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -345,7 +345,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) switch (KnockbackLevel) { case 1: AdditionalSpeed.Set(5, 0.3, 5); break; - case 2: AdditionalSpeed.Set(8, 0.3, 8); break; + case 2: AdditionalSpeed.Set(8, 0.3, 8); break; default: break; } AddSpeed(a_TDI.Knockback + AdditionalSpeed); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 7abe5db37..88f8528e9 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -485,7 +485,7 @@ protected: /// Whether the entity is capable of taking fire or lava damage. bool m_IsFireproof; - + /// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire()) int m_TicksSinceLastBurnDamage; diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index e437c24ef..ed225b8e6 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -6,7 +6,7 @@ cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) - : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98) + : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98) , m_Reward(a_Reward) , m_Timer(0.f) { @@ -19,7 +19,7 @@ cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward) - : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98) + : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98) , m_Reward(a_Reward) , m_Timer(0.f) { diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index d7a7ba943..32d2b226d 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -10,7 +10,7 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) - : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8) + : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8) , m_BlockFace(a_BlockFace) { SetMaxHealth(1); diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 144c6d5aa..f0b0c8c65 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -10,7 +10,7 @@ cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) - : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z) + : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z) , m_Item(E_BLOCK_AIR) , m_Rotation(0) { diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 18df1a210..aab534f41 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -85,7 +85,7 @@ protected: cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) - : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2) + : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2) , m_Timer(0.f) , m_Item(a_Item) , m_bCollected(false) diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index d50941280..d7c5d2b26 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -32,7 +32,7 @@ public: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - bool CollectedBy(cPlayer * a_Dest); // tolua_export + bool CollectedBy(cPlayer * a_Dest); // tolua_export virtual void Tick(float a_Dt, cChunk & a_Chunk) override; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6e7623f4a..a356ebba7 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1347,7 +1347,7 @@ void cPlayer::SetVisible(bool a_bVisible) if (!a_bVisible && m_bVisible) { m_bVisible = false; - m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients + m_World->BroadcastDestroyEntity(*this, m_ClientHandle); // Destroy on all clients } } @@ -1455,7 +1455,7 @@ bool cPlayer::IsInGroup( const AString & a_Group ) void cPlayer::ResolvePermissions() { - m_ResolvedPermissions.clear(); // Start with an empty map yo~ + m_ResolvedPermissions.clear(); // Start with an empty map // Copy all player specific permissions into the resolved permissions map for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr ) @@ -1483,7 +1483,7 @@ void cPlayer::ResolveGroups() m_ResolvedGroups.clear(); // Get a complete resolved list of all groups the player is in - std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates + std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates GroupList ToIterate; for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr ) { @@ -1501,7 +1501,7 @@ void cPlayer::ResolveGroups() else { AllGroups[ CurrentGroup ] = true; - m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list + m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list const cGroup::GroupList & Inherits = CurrentGroup->GetInherits(); for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr ) { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 0eef3e6e1..7c287d41b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -119,11 +119,11 @@ public: void SetTouchGround( bool a_bTouchGround ); inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; } - double GetEyeHeight(void) const; // tolua_export - Vector3d GetEyePosition(void) const; // tolua_export + double GetEyeHeight(void) const; // tolua_export + Vector3d GetEyePosition(void) const; // tolua_export inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export 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 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 */ @@ -239,15 +239,15 @@ public: typedef std::list< std::string > StringList; /** Adds a player to existing group or creates a new group when it doesn't exist */ - void AddToGroup( const AString & a_GroupName ); // tolua_export + void AddToGroup( const AString & a_GroupName ); // tolua_export /** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */ - void RemoveFromGroup( const AString & a_GroupName ); // tolua_export + void RemoveFromGroup( const AString & a_GroupName ); // tolua_export - bool HasPermission( const AString & a_Permission ); // tolua_export - const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << - StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << - bool IsInGroup( const AString & a_Group ); // tolua_export + bool HasPermission( const AString & a_Permission ); // tolua_export + const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << + StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << + bool IsInGroup( const AString & a_Group ); // tolua_export // tolua_begin @@ -326,10 +326,10 @@ public: virtual void Killed(cEntity * a_Victim) override; - void Respawn(void); // tolua_export + void Respawn(void); // tolua_export - void SetVisible( bool a_bVisible ); // tolua_export - bool IsVisible(void) const { return m_bVisible; } // tolua_export + void SetVisible( bool a_bVisible ); // tolua_export + bool IsVisible(void) const { return m_bVisible; } // tolua_export /** Moves the player to the specified world. Returns true if successful, false on failure (world not found). */ @@ -345,7 +345,7 @@ public: Returns true on success, false on failure. */ bool LoadFromFile(const AString & a_FileName); - void LoadPermissionsFromDisk(void); // tolua_export + void LoadPermissionsFromDisk(void); // tolua_export const AString & GetLoadedWorldName() { return m_LoadedWorldName; } diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index f543846d2..3571b29d4 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -555,14 +555,14 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons { AString SVG; SVG.reserve(m_Points.size() * 20 + 200); - AppendPrintf(SVG, "m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; - } - SVG.append("\"/>\n"); + } + SVG.append("\"/>\n"); return SVG; } #endif // _DEBUG diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 3f8f77f09..0947eeae5 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -228,10 +228,10 @@ void cChunkGenerator::Execute(void) continue; } - cChunkCoords coords = m_Queue.front(); // Get next coord from queue - m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue + cChunkCoords coords = m_Queue.front(); // Get next coord from queue + m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT); - Lock.Unlock(); // Unlock ASAP + Lock.Unlock(); // Unlock ASAP m_evtRemoved.Set(); // Display perf info once in a while: diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 2e5732929..fdeb86e73 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -199,7 +199,7 @@ protected: // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; - /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful + /// Tries to place a spring at the specified coords, checks neighbors. Returns true if successful bool TryPlaceSpring(cChunkDesc & a_ChunkDesc, int x, int y, int z); } ; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 8f62669e7..86e27d8ed 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -283,25 +283,25 @@ void cStructGenRavines::cRavine::FinishLinear(void) AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const { AString SVG; - AppendPrintf(SVG, "m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; - } - SVG.append("\"/>\n"); - - // Base point highlight: - AppendPrintf(SVG, "\n", + } + SVG.append("\"/>\n"); + + // Base point highlight: + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX - 5, a_OffsetZ + m_OriginZ, a_OffsetX + m_OriginX + 5, a_OffsetZ + m_OriginZ ); - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ - 5, a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ + 5 ); // A gray line from the base point to the first point of the ravine, for identification: - AppendPrintf(SVG, "\n", + AppendPrintf(SVG, "\n", a_OffsetX + m_OriginX, a_OffsetZ + m_OriginZ, a_OffsetX + m_Points.front().m_BlockX, a_OffsetZ + m_Points.front().m_BlockZ ); diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index fdec2425d..cade923c9 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -95,7 +95,7 @@ public: return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector); } -} ; +}; diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 0c07cd422..6350a38ba 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -63,7 +63,7 @@ class cSweepEntityCallback : { public: cSweepEntityCallback(Vector3d a_PlayerPos) : - m_PlayerPos(a_PlayerPos) + m_PlayerPos(a_PlayerPos) { } diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 3e02a43fa..178bc2fca 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -459,13 +459,13 @@ bool cItemHandler::IsTool() { // TODO: Rewrite this to list all tools specifically return - (m_ItemType >= 256 && m_ItemType <= 259) - || (m_ItemType == 261) - || (m_ItemType >= 267 && m_ItemType <= 279) - || (m_ItemType >= 283 && m_ItemType <= 286) - || (m_ItemType >= 290 && m_ItemType <= 294) - || (m_ItemType == 325) - || (m_ItemType == 346); + ((m_ItemType >= 256) && (m_ItemType <= 259)) || + (m_ItemType == 261) || + ((m_ItemType >= 267) && (m_ItemType <= 279)) || + ((m_ItemType >= 283) && (m_ItemType <= 286)) || + ((m_ItemType >= 290) && (m_ItemType <= 294)) || + (m_ItemType == 325) || + (m_ItemType == 346); } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index df2572976..ba901df4e 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -325,7 +325,7 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) AddSpeedZ(Distance.z); if (m_EMState == ESCAPING) - { // Runs Faster when escaping :D otherwise they just walk away + { // Runs Faster when escaping :D otherwise they just walk away SetSpeedX (GetSpeedX() * 2.f); SetSpeedZ (GetSpeedZ() * 2.f); } diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index 60e5564e4..d919c4744 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -44,48 +44,64 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* #endif } + + + + cSemaphore::~cSemaphore() { #ifdef _WIN32 CloseHandle( m_Handle ); #else - if( m_bNamed ) - { - if( sem_close( (sem_t*)m_Handle ) != 0 ) - { - LOG("ERROR: Could not close cSemaphore. (%i)", errno); - } - } - else - { - sem_destroy( (sem_t*)m_Handle ); - delete (sem_t*)m_Handle; - } + if( m_bNamed ) + { + if( sem_close( (sem_t*)m_Handle ) != 0 ) + { + LOG("ERROR: Could not close cSemaphore. (%i)", errno); + } + } + else + { + sem_destroy( (sem_t*)m_Handle ); + delete (sem_t*)m_Handle; + } m_Handle = 0; #endif } + + + + void cSemaphore::Wait() { #ifndef _WIN32 - if( sem_wait( (sem_t*)m_Handle ) != 0) - { - LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); - } + if( sem_wait( (sem_t*)m_Handle ) != 0) + { + LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); + } #else WaitForSingleObject( m_Handle, INFINITE); #endif } + + + + void cSemaphore::Signal() { #ifndef _WIN32 if( sem_post( (sem_t*)m_Handle ) != 0 ) { - LOG("ERROR: Could not signal cSemaphore. (%i)", errno); + LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } #else ReleaseSemaphore( m_Handle, 1, NULL ); #endif } + + + + diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index b18d918fa..223a8b855 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -14,6 +14,6 @@ void cSleep::MilliSleep( unsigned int a_MilliSeconds ) #ifdef _WIN32 Sleep(a_MilliSeconds); // Don't tick too much #else - usleep(a_MilliSeconds*1000); + usleep(a_MilliSeconds*1000); #endif } diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 674e37757..084e0810e 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -91,7 +91,7 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; - HANDLE hThread = CreateThread( 0 // security + HANDLE hThread = CreateThread(NULL // security ,0 // stack size , (LPTHREAD_START_ROUTINE) MyThread // function name ,this // parameters diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index e2960d0c3..1ac035e26 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -760,7 +760,7 @@ void cProtocol125::SendPlayerMoveLook(void) ); */ - WriteByte (PACKET_PLAYER_MOVE_LOOK); + WriteByte(PACKET_PLAYER_MOVE_LOOK); cPlayer * Player = m_Client->GetPlayer(); WriteDouble(Player->GetPosX()); WriteDouble(Player->GetStance() + 0.03); // Add a small amount so that the player doesn't start inside a block @@ -1005,10 +1005,10 @@ void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp void cProtocol125::SendStatistics(const cStatManager & a_Manager) { /* NOTE: - * Versions prior to minecraft 1.7 use an incremental statistic sync - * method. The current setup does not allow us to implement that, because - * of performance considerations. - */ + Versions prior to minecraft 1.7 use an incremental statistic sync + method. The current setup does not allow us to implement that, because + of performance considerations. + */ #if 0 for (unsigned int i = 0; i < (unsigned int)statCount; ++i) { @@ -1121,7 +1121,7 @@ void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc cCSLock Lock(m_CSPacket); WriteByte(PACKET_USE_BED); WriteInt (a_Entity.GetUniqueID()); - WriteByte(0); // Unknown byte only 0 has been observed + WriteByte(0); // Unknown byte only 0 has been observed WriteInt (a_BlockX); WriteByte((Byte)a_BlockY); WriteInt (a_BlockZ); @@ -1344,11 +1344,11 @@ int cProtocol125::ParseArmAnim(void) int cProtocol125::ParseBlockDig(void) { - HANDLE_PACKET_READ(ReadChar, char, Status); + HANDLE_PACKET_READ(ReadChar, char, Status); HANDLE_PACKET_READ(ReadBEInt, int, PosX); - HANDLE_PACKET_READ(ReadByte, Byte, PosY); + HANDLE_PACKET_READ(ReadByte, Byte, PosY); HANDLE_PACKET_READ(ReadBEInt, int, PosZ); - HANDLE_PACKET_READ(ReadChar, char, BlockFace); + HANDLE_PACKET_READ(ReadChar, char, BlockFace); m_Client->HandleLeftClick(PosX, PosY, PosZ, static_cast(BlockFace), Status); return PARSE_OK; } diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 45cda944b..37a9fdf47 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -2707,9 +2707,10 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity) // The following expression makes Minecarts shake more with less health or higher damage taken // It gets half the maximum health, and takes it away from the current health minus the half health: - /* Health: 5 | 3 - (5 - 3) = 1 (shake power) - Health: 3 | 3 - (3 - 3) = 3 - Health: 1 | 3 - (1 - 3) = 5 + /* + Health: 5 | 3 - (5 - 3) = 1 (shake power) + Health: 3 | 3 - (3 - 3) = 3 + Health: 1 | 3 - (1 - 3) = 5 */ WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4); WriteByte(0x52); diff --git a/src/Simulator/DelayedFluidSimulator.h b/src/Simulator/DelayedFluidSimulator.h index fe59f6dd6..8a6c26c7a 100644 --- a/src/Simulator/DelayedFluidSimulator.h +++ b/src/Simulator/DelayedFluidSimulator.h @@ -70,7 +70,7 @@ protected: /* Slots: | 0 | 1 | ... | m_AddSlotNum | m_SimSlotNum | ... | m_TickDelay - 1 | - adding blocks here ^ | ^ simulating here + | adding blocks here ^ | ^ simulating here */ /// Called from SimulateChunk() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation. diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 99aa11728..499e204a1 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -137,7 +137,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a return Y_MINUS; */ - NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted + NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted int X = 0, Z = 0; // Lowest Pos will be stored here if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) // check for upper block to flow because this also affects the flowing direction diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index eb12c08e0..8e5e40fb5 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -739,7 +739,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int // Create a variable holding my meta to avoid multiple lookups. NIBBLETYPE a_Meta = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ); bool IsOn = (a_MyState == E_BLOCK_REDSTONE_REPEATER_ON); - + if (!IsRepeaterLocked(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta)) // If we're locked, change nothing. Otherwise: { bool IsSelfPowered = IsRepeaterPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta); diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h index 878f88b71..79740a8f6 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator.h @@ -294,7 +294,7 @@ private: case E_BLOCK_WOODEN_PRESSURE_PLATE: case E_BLOCK_PISTON: { - return true; + return true; } default: return false; } diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 3dc5c3849..7f37159b7 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -135,7 +135,7 @@ class cSlotAreaHotBar : typedef cSlotAreaInventoryBase super; public: - cSlotAreaHotBar(cWindow & a_ParentWindow) : + cSlotAreaHotBar(cWindow & a_ParentWindow) : cSlotAreaInventoryBase(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow) { } @@ -150,7 +150,7 @@ class cSlotAreaArmor : public cSlotAreaInventoryBase { public: - cSlotAreaArmor(cWindow & a_ParentWindow) : + cSlotAreaArmor(cWindow & a_ParentWindow) : cSlotAreaInventoryBase(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow) { } diff --git a/src/WorldStorage/MapSerializer.h b/src/WorldStorage/MapSerializer.h index eb7678a08..4fa40f6f9 100644 --- a/src/WorldStorage/MapSerializer.h +++ b/src/WorldStorage/MapSerializer.h @@ -52,10 +52,9 @@ private: /** Utility class used to serialize item ID counts. - * - * In order to perform bounds checking (while loading), - * the last registered ID of each item is serialized to an NBT file. - */ +In order to perform bounds checking (while loading), +the last registered ID of each item is serialized to an NBT file. +*/ class cIDCountSerializer { public: From b2716c720eb237b961470c569ef491558fcc34d3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 23:25:21 +0200 Subject: [PATCH 267/280] Fixed code style in Trees.cpp. The src folder now has zero BasicStyle violations. --- src/Generating/Trees.cpp | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index eac086de6..b7a08999d 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -41,42 +41,42 @@ static const sCoords Corners[] = static const sCoords BigO1[] = { - {0, -1}, - {-1, 0}, {1, 0}, - {0, 1}, + /* -1 */ {0, -1}, + /* 0 */ {-1, 0}, {1, 0}, + /* 1 */ {0, 1}, } ; static const sCoords BigO2[] = { - {-1, -2}, {0, -2}, {1, -2}, - {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, - {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, - {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, - {-1, 2}, {0, 2}, {1, 2}, + /* -2 */ {-1, -2}, {0, -2}, {1, -2}, + /* -1 */ {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, + /* 0 */ {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, + /* 1 */ {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, + /* 2 */ {-1, 2}, {0, 2}, {1, 2}, } ; static const sCoords BigO3[] = { - {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, - {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, - {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, - {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, - {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, - {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, - {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, + /* -3 */ {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, + /* -2 */ {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, + /* -1 */ {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, + /* 0 */ {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, + /* 1 */ {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, + /* 2 */ {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, + /* 3 */ {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, } ; static const sCoords BigO4[] = // Part of Big Jungle tree { - {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4}, - {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3}, - {-4, -2}, {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, {4, -2}, - {-4, -1}, {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, {4, -1}, - {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, - {-4, 1}, {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, - {-4, 2}, {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, - {-3, 3}, {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, {3, 3}, - {-2, 4}, {-1, 4}, {0, 4}, {1, 4}, {2, 4}, + /* -4 */ {-2, -4}, {-1, -4}, {0, -4}, {1, -4}, {2, -4}, + /* -3 */ {-3, -3}, {-2, -3}, {-1, -3}, {0, -3}, {1, -3}, {2, -3}, {3, -3}, + /* -2 */ {-4, -2}, {-3, -2}, {-2, -2}, {-1, -2}, {0, -2}, {1, -2}, {2, -2}, {3, -2}, {4, -2}, + /* -1 */ {-4, -1}, {-3, -1}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, {4, -1}, + /* 0 */ {-4, 0}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, + /* 1 */ {-4, 1}, {-3, 1}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, + /* 2 */ {-4, 2}, {-3, 2}, {-2, 2}, {-1, 2}, {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, + /* 3 */ {-3, 3}, {-2, 3}, {-1, 3}, {0, 3}, {1, 3}, {2, 3}, {3, 3}, + /* 4 */ {-2, 4}, {-1, 4}, {0, 4}, {1, 4}, {2, 4}, } ; From bc94ad4b5ae089fe5ee984a827a0575926102bdc Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 14:34:58 -0700 Subject: [PATCH 268/280] Fixed NULL being passed instead of a double to AddEntityEffect --- 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 a356ebba7..5c3303cb2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -580,7 +580,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::FoodPoison(int a_NumTicks) { - AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, NULL); + AddEntityEffect(cEntityEffect::effHunger, a_NumTicks, 0, 1); } From 33bd78dcdd1f080ef5d3b47b0e24099227a8a5d5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:26:27 +0200 Subject: [PATCH 269/280] Skeletons should spawn with a bow in the hand. Fixes #1184 --- src/Mobs/Skeleton.cpp | 15 +++++++++++++++ src/Mobs/Skeleton.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 0641a3d57..2f57bedeb 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -4,6 +4,7 @@ #include "Skeleton.h" #include "../World.h" #include "../Entities/ArrowEntity.h" +#include "ClientHandle.h" @@ -90,3 +91,17 @@ void cSkeleton::Attack(float a_Dt) m_AttackInterval = 0.0; } } + + + + + +void cSkeleton::SpawnOn(cClientHandle & a_ClientHandle) +{ + super::SpawnOn(a_ClientHandle); + a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_BOW)); +} + + + + diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 8f31b42e1..229462d63 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -20,6 +20,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; virtual void MoveToPosition(const Vector3f & a_Position) override; virtual void Attack(float a_Dt) override; + virtual void SpawnOn(cClientHandle & a_ClientHandle) override; + bool IsWither(void) const { return m_bIsWither; }; private: From 57d415e38be306eb933bf71d262f4ea4f4a1036c Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:28:56 +0200 Subject: [PATCH 270/280] Added me to the CONTRIBUTORS list. I hope it is ok. --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 09515aa6b..925e8f35b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -28,5 +28,6 @@ UltraCoderRU worktycho xoft Yeeeeezus (Donated AlchemistVillage prefabs) +Howaner Please add yourself to this list if you contribute to MCServer. From fc6a5878df2615262eb53cb1ca4ccfcf1e299dc6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 18 Jul 2014 01:45:45 +0200 Subject: [PATCH 271/280] Removed special character in APIDump --- MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua index 4c91ea89e..9a0e036b9 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua @@ -2,7 +2,7 @@ return { HOOK_PLAYER_USED_BLOCK = { - CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", + CalledWhen = "A player has just used a block (chest, furnace...). Notification only.", DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename Desc = [[ This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a From 32b25ec7f799ca15fdcdc3e9e9535c798d0cc523 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 18:34:47 -0700 Subject: [PATCH 272/280] Generator: removed rnd definitions that are never read --- src/Generating/MineShafts.cpp | 1 - src/Generating/StructGen.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index e951b90fa..0532aff39 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -997,7 +997,6 @@ cMineShaft * cMineShaftCrossing::CreateAndFit( BoundingBox.p2.y -= 4; } } - rnd >>= 2; switch (a_Direction) { case dirXP: BoundingBox.p2.x += 4; BoundingBox.p1.z -= 2; BoundingBox.p2.z += 2; break; diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 5deded17d..054eec345 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -484,7 +484,6 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a const int BubbleY = 4 + (Rnd & 0x01); // 4 .. 5 Rnd >>= 1; const int BubbleZ = BubbleR + (Rnd % Range); - Rnd >>= 4; const int HalfR = BubbleR / 2; // 1 .. 2 const int RSquared = BubbleR * BubbleR; for (int y = -HalfR; y <= HalfR; y++) From 33b0a719da8ed8f76397f6003a5a9afa7079c090 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 18:39:44 -0700 Subject: [PATCH 273/280] ProtocolRecognizer.cpp: removed unused NumBytesRead --- src/Protocol/ProtocolRecognizer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index d3aae65fe..3991b84de 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -953,7 +953,6 @@ bool cProtocolRecognizer::TryRecognizeLengthlessProtocol(void) bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRemaining) { UInt32 PacketType; - UInt32 NumBytesRead = (UInt32)m_Buffer.GetReadableSpace(); if (!m_Buffer.ReadVarInt(PacketType)) { return false; @@ -972,7 +971,6 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema { return false; } - NumBytesRead -= (UInt32)m_Buffer.GetReadableSpace(); switch (ProtocolVersion) { case PROTO_VERSION_1_7_2: From ffe44c13d0ce037efb01544b96fe0756d64b8517 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 17 Jul 2014 23:25:14 -0700 Subject: [PATCH 274/280] Moved ChatColor.h out of defines where it was not needed --- src/Defines.h | 1 - src/Entities/Player.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Defines.h b/src/Defines.h index 877970ab8..f57e63c7f 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -1,7 +1,6 @@ #pragma once -#include "ChatColor.h" #include #include diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 5c3303cb2..ea11926b8 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2,6 +2,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Player.h" +#include "../ChatColor.h" #include "../Server.h" #include "../UI/Window.h" #include "../UI/WindowOwner.h" From d52a51f7b6530d2a63682798472840d7261ebad4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:18:00 +0200 Subject: [PATCH 275/280] Removed duplicate IPvX labels. --- src/HTTPServer/HTTPServer.cpp | 4 ++-- src/RCONServer.cpp | 4 ++-- src/Server.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp index b7edf7829..8eabe5cb2 100644 --- a/src/HTTPServer/HTTPServer.cpp +++ b/src/HTTPServer/HTTPServer.cpp @@ -122,8 +122,8 @@ class cDebugCallbacks : // cHTTPServer: cHTTPServer::cHTTPServer(void) : - m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer IPv4"), - m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer IPv6"), + m_ListenThreadIPv4(*this, cSocket::IPv4, "WebServer"), + m_ListenThreadIPv6(*this, cSocket::IPv6, "WebServer"), m_Callbacks(NULL) { } diff --git a/src/RCONServer.cpp b/src/RCONServer.cpp index 28cb1e03b..141c67d1b 100644 --- a/src/RCONServer.cpp +++ b/src/RCONServer.cpp @@ -78,8 +78,8 @@ protected: cRCONServer::cRCONServer(cServer & a_Server) : m_Server(a_Server), - m_ListenThread4(*this, cSocket::IPv4, "RCON IPv4"), - m_ListenThread6(*this, cSocket::IPv6, "RCON IPv6") + m_ListenThread4(*this, cSocket::IPv4, "RCON"), + m_ListenThread6(*this, cSocket::IPv6, "RCON") { } diff --git a/src/Server.cpp b/src/Server.cpp index bc9644804..10a354a36 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -105,8 +105,8 @@ void cServer::cTickThread::Execute(void) // cServer: cServer::cServer(void) : - m_ListenThreadIPv4(*this, cSocket::IPv4, "Client IPv4"), - m_ListenThreadIPv6(*this, cSocket::IPv6, "Client IPv6"), + m_ListenThreadIPv4(*this, cSocket::IPv4, "Client"), + m_ListenThreadIPv6(*this, cSocket::IPv6, "Client"), m_PlayerCount(0), m_PlayerCountDiff(0), m_ClientViewDistance(0), From 2df5e26d3b7f08ef7d120511705fa0b75a44783e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:57:34 +0200 Subject: [PATCH 276/280] Fixed spaces before commas. --- src/BiomeDef.cpp | 2 +- src/BlockEntities/ChestEntity.cpp | 4 ++-- src/ChunkMap.cpp | 4 ++-- src/Generating/FinishGen.cpp | 4 ++-- src/Generating/HeiGen.cpp | 4 ++-- src/Mobs/Monster.h | 6 +++--- src/Simulator/IncrementalRedstoneSimulator.cpp | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 9852b3dd9..d680377e2 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -15,7 +15,7 @@ static struct { const char * m_String; } g_BiomeMap[] = { - {biOcean, "Ocean"} , + {biOcean, "Ocean"}, {biPlains, "Plains"}, {biDesert, "Desert"}, {biExtremeHills, "ExtremeHills"}, diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp index 9f50365e9..21e1f6ba2 100644 --- a/src/BlockEntities/ChestEntity.cpp +++ b/src/BlockEntities/ChestEntity.cpp @@ -169,8 +169,8 @@ void cChestEntity::OpenNewWindow(void) if ( m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) || m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) || - m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) || - m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl) + m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) || + m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl) ) { // The double-chest window has been opened in the callback diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 9f280f1c5..e91f77d27 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2762,8 +2762,8 @@ cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_Ch { cChunk * neixm = (LocalX > 0) ? m_Chunks[Index - 1] : m_Parent->FindChunk(a_ChunkX - 1, a_ChunkZ); cChunk * neixp = (LocalX < LAYER_SIZE - 1) ? m_Chunks[Index + 1] : m_Parent->FindChunk(a_ChunkX + 1, a_ChunkZ); - cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ - 1); - cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX , a_ChunkZ + 1); + cChunk * neizm = (LocalZ > 0) ? m_Chunks[Index - LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ - 1); + cChunk * neizp = (LocalZ < LAYER_SIZE - 1) ? m_Chunks[Index + LAYER_SIZE] : m_Parent->FindChunk(a_ChunkX, a_ChunkZ + 1); m_Chunks[Index] = new cChunk(a_ChunkX, 0, a_ChunkZ, m_Parent, m_Parent->GetWorld(), neixm, neixp, neizm, neizp, m_Pool); } return m_Chunks[Index]; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 13871bbd8..00a93023d 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -193,8 +193,8 @@ bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_ if ( !IsWater(a_ChunkDesc.GetBlockType(a_RelX - 1, a_RelY, a_RelZ)) && !IsWater(a_ChunkDesc.GetBlockType(a_RelX + 1, a_RelY, a_RelZ)) && - !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ - 1)) && - !IsWater(a_ChunkDesc.GetBlockType(a_RelX , a_RelY, a_RelZ + 1)) + !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ - 1)) && + !IsWater(a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ + 1)) ) { return false; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index b02e06951..3df1a90ff 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -283,7 +283,7 @@ void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightM { hei = 250; } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); + cChunkDef::SetHeight(a_HeightMap, x, z, hei); } // for x } // for z } @@ -345,7 +345,7 @@ void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Heigh { hei = 250; } - cChunkDef::SetHeight(a_HeightMap, x , z, hei); + cChunkDef::SetHeight(a_HeightMap, x, z, hei); } // for x } // for z } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 750040468..6e14e3b18 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -76,9 +76,9 @@ public: enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality; /** Creates the mob object. - * If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() - * a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs , 2012_12_22)) - * a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively + If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() + a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22)) + a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively */ cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp index 8e5e40fb5..3dd6417dc 100644 --- a/src/Simulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator.cpp @@ -724,7 +724,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int X Axis ----> - Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX , a_RelBlockY, a_RelBlockZ) lookup: + Repeater directions, values from a cWorld::GetBlockMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) lookup: East (Right) (X+): 0x1 West (Left) (X-): 0x3 @@ -1723,7 +1723,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc { continue; } - 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) + 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 From 204b59117225268a569fb68614bb59add4d53a03 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Jul 2014 09:58:29 +0200 Subject: [PATCH 277/280] CheckBasicStyle: Proper spaces with commas. --- src/CheckBasicStyle.lua | 69 ++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua index f9bb41975..6aad4125d 100644 --- a/src/CheckBasicStyle.lua +++ b/src/CheckBasicStyle.lua @@ -6,13 +6,16 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th - Tabs for indentation, spaces for alignment - Trailing whitespace on non-empty lines - Two spaces between code and line-end comment ("//") - - (TODO) Spaces around +, -, (cannot check /, * or & due to their other usage - comment, ptr deref, address-of) + - Spaces after comma, not before (except in #define argument list) - (TODO) Spaces before *, /, & - - (TODO) Spaces after , - (TODO) Hex numbers with even digit length - (TODO) Hex numbers in lowercase - (TODO) Braces not on the end of line - (TODO) Line dividers (////...) exactly 80 slashes + - (TODO) Not using "* "-style doxy comments continuation lines + +Violations that cannot be checked easily: + - Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables) Reports all violations on stdout in a form that is readable by Visual Studio's parser, so that dblclicking the line brings the editor directly to the violation. @@ -85,6 +88,45 @@ end +--- Searches for the specified pattern, if found, reports it as a violation with the given message +local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern, a_Message) + local patStart, patEnd = a_Line:find(a_Pattern) + if not(patStart) then + return + end + ReportViolation(a_FileName, a_LineNum, a_Message .. "(" .. patStart .. " .. " .. patEnd .. ")") +end + + + + + +local g_ViolationPatterns = +{ + -- Check against indenting using spaces: + {"^\t* +", "Indenting with a space"}, + + -- Check against alignment using tabs: + {"[^%s]\t+[^%s]", "Aligning with a tab"}, + + -- Check against trailing whitespace: + {"[^%s]%s+\n", "Trailing whitespace"}, + + -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): + {"[^%s] //", "Needs at least two spaces in front of a \"//\"-style comment"}, + + -- Check that all "//"-style comments have at least one spaces after: + {"%s//[^%s/*<]", "Needs a space after a \"//\"-style comment"}, + + -- Check that all commas have spaces after them and not in front of them: + {" ,", "Extra space before a \",\""}, + {"^\t*[^#].*,[^%s]", "Needs a space after a \",\""}, -- Anywhere except lines starting with "#" - avoid #define params +} + + + + + --- Processes one file local function ProcessFile(a_FileName) assert(type(a_FileName) == "string") @@ -113,26 +155,11 @@ local function ProcessFile(a_FileName) all:gsub("\r\n", "\n") -- normalize CRLF into LF-only string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines function(a_Line) - -- Check against indenting using spaces: - if (a_Line:find("^\t* +")) then -- Find any number of tabs at the start of line (incl 0), followed by a space - ReportViolation(a_FileName, lineCounter, "Indenting with a space") - end - -- Check against alignment using tabs: - if (a_Line:find("[^%s]\t+[^%s]")) then -- Find any number of tabs after non-whitespace followed by non-whitespace - ReportViolation(a_FileName, lineCounter, "Aligning with a tab") - end - -- Check against trailing whitespace: - if (a_Line:find("[^%s]%s+\n")) then -- Find any whitespace after non-whitespace at the end of line - ReportViolation(a_FileName, lineCounter, "Trailing whitespace") - end - -- Check that all "//"-style comments have at least two spaces in front (unless alone on line): - if (a_Line:find("[^%s] //")) then - ReportViolation(a_FileName, lineCounter, "Needs at least two spaces in front of a \"//\"-style comment") - end - -- Check that all "//"-style comments have at least one spaces after: - if (a_Line:find("%s//[^%s/*<]")) then - ReportViolation(a_FileName, lineCounter, "Needs a space after a \"//\"-style comment") + -- Check against each violation pattern: + for _, pat in ipairs(g_ViolationPatterns) do + ReportViolationIfFound(a_Line, a_FileName, lineCounter, pat[1], pat[2]) end + lineCounter = lineCounter + 1 end ) From 9529a4255999efc0970d82385ef1ff07c62a7a02 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 01:56:26 -0700 Subject: [PATCH 278/280] Fixed creative players not being able to drink Fixes #1215 --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 97466c331..58247a836 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1209,11 +1209,12 @@ 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(EquippedDamage)) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage))) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage)) + if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) && + ItemHandler->IsFood()) { - // The player is satiated, they cannot eat + // The player is satiated or in creative, and trying to eat return; } m_Player->StartEating(); From 38aeaa64eda9afc645f3d864316cd02d3990e73a Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 02:02:28 -0700 Subject: [PATCH 279/280] MCServer supports Minecraft v1.7.10 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0f1cde35..85ae459a0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ MCServer is a Minecraft server that is written in C++ and designed to be efficie MCServer can run on PCs, Macs, and *nix. This includes android phones and tablets as well as Raspberry Pis. -We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.9. +We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.7.10. Installation ------------ From f1be1eb6743700515de3a522898ba99680cf24c0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Jul 2014 10:47:00 +0100 Subject: [PATCH 280/280] Monster fixes * Fixes #1203 * Fixes #627 --- lib/polarssl | 2 +- src/BlockInfo.cpp | 4 ---- src/Mobs/Monster.cpp | 27 +-------------------------- src/Mobs/Monster.h | 1 - src/Mobs/Skeleton.cpp | 2 +- src/Mobs/Skeleton.h | 2 +- src/Mobs/Zombie.cpp | 2 +- src/Mobs/Zombie.h | 2 +- 8 files changed, 6 insertions(+), 36 deletions(-) diff --git a/lib/polarssl b/lib/polarssl index 784b04ff9..1ed82759c 160000 --- a/lib/polarssl +++ b/lib/polarssl @@ -1 +1 @@ -Subproject commit 784b04ff9afd5faeaeb15c3fa159ff98adf55182 +Subproject commit 1ed82759c68f92c4acc7e3f33b850cf9f01c8aba diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index b4b98a2f0..97e89359f 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -496,9 +496,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) 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; @@ -530,7 +527,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) 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: diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index ba901df4e..1369746df 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -115,8 +115,6 @@ void cMonster::TickPathFinding() const int PosY = POSY_TOINT; const int PosZ = POSZ_TOINT; - m_FinalDestination.y = (double)FindFirstNonAirBlockPosition(m_FinalDestination.x, m_FinalDestination.z); - std::vector m_PotentialCoordinates; m_TraversedCoordinates.push_back(Vector3i(PosX, PosY, PosZ)); @@ -201,19 +199,6 @@ void cMonster::TickPathFinding() -void cMonster::MoveToPosition(const Vector3f & a_Position) -{ - FinishPathFinding(); - - m_FinalDestination = a_Position; - m_bMovingToDestination = true; - TickPathFinding(); -} - - - - - void cMonster::MoveToPosition(const Vector3d & a_Position) { FinishPathFinding(); @@ -227,15 +212,7 @@ void cMonster::MoveToPosition(const Vector3d & a_Position) bool cMonster::IsCoordinateInTraversedList(Vector3i a_Coords) { - for (std::vector::const_iterator itr = m_TraversedCoordinates.begin(); itr != m_TraversedCoordinates.end(); ++itr) - { - if (itr->Equals(a_Coords)) - { - return true; - } - } - - return false; + return (std::find(m_TraversedCoordinates.begin(), m_TraversedCoordinates.end(), a_Coords) != m_TraversedCoordinates.end()); } @@ -296,8 +273,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) { if (m_bOnGround) { - m_Destination.y = FindFirstNonAirBlockPosition(m_Destination.x, m_Destination.z); - if (DoesPosYRequireJump((int)floor(m_Destination.y))) { m_bOnGround = false; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 6e14e3b18..4af7cf4f1 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -92,7 +92,6 @@ public: virtual void KilledBy(TakeDamageInfo & a_TDI) override; - virtual void MoveToPosition(const Vector3f & a_Position); virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual bool ReachedDestination(void); diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index 2f57bedeb..cd707f4bb 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -48,7 +48,7 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cSkeleton::MoveToPosition(const Vector3f & a_Position) +void cSkeleton::MoveToPosition(const Vector3d & a_Position) { // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index 229462d63..efb670c83 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cSkeleton); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void MoveToPosition(const Vector3d & a_Position) override; virtual void Attack(float a_Dt) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp index 725790ed9..30225c32d 100644 --- a/src/Mobs/Zombie.cpp +++ b/src/Mobs/Zombie.cpp @@ -42,7 +42,7 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cZombie::MoveToPosition(const Vector3f & a_Position) +void cZombie::MoveToPosition(const Vector3d & a_Position) { // If the destination is sufficiently skylight challenged AND the skeleton isn't on fire then block the movement if ( diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h index 1ba368f9c..c56409570 100644 --- a/src/Mobs/Zombie.h +++ b/src/Mobs/Zombie.h @@ -17,7 +17,7 @@ public: CLASS_PROTODEF(cZombie); virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual void MoveToPosition(const Vector3f & a_Position) override; + virtual void MoveToPosition(const Vector3d & a_Position) override; bool IsVillagerZombie(void) const {return m_IsVillagerZombie; } bool IsConverting (void) const {return m_IsConverting; }