From 9e4a5f824ae88e3a19de6a14db91b43c1759e29e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 30 Sep 2014 22:20:21 +0100 Subject: Removed WSSCompact --- src/BlockEntities/BeaconEntity.cpp | 62 -------------------------------------- 1 file changed, 62 deletions(-) (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index dcf659f47..02f45a097 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -303,68 +303,6 @@ void cBeaconEntity::UsedBy(cPlayer * a_Player) -bool cBeaconEntity::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++; - } - - m_BeaconLevel = (char)a_Value.get("Level", 0).asInt(); - int PrimaryEffect = a_Value.get("PrimaryEffect", 0).asInt(); - int SecondaryEffect = a_Value.get("SecondaryEffect", 0).asInt(); - - if ((PrimaryEffect >= 0) && (PrimaryEffect <= (int)cEntityEffect::effSaturation)) - { - m_PrimaryEffect = (cEntityEffect::eType)PrimaryEffect; - } - - if ((SecondaryEffect >= 0) && (SecondaryEffect <= (int)cEntityEffect::effSaturation)) - { - m_SecondaryEffect = (cEntityEffect::eType)SecondaryEffect; - } - - return true; -} - - - - - -void cBeaconEntity::SaveToJson(Json::Value& a_Value) -{ - a_Value["x"] = m_PosX; - a_Value["y"] = m_PosY; - a_Value["z"] = m_PosZ; - - Json::Value AllSlots; - int NumSlots = m_Contents.GetNumSlots(); - for (int i = 0; i < NumSlots; i++) - { - Json::Value Slot; - m_Contents.GetSlot(i).GetJson(Slot); - AllSlots.append(Slot); - } - a_Value["Slots"] = AllSlots; - - a_Value["Level"] = m_BeaconLevel; - a_Value["PrimaryEffect"] = (int)m_PrimaryEffect; - a_Value["SecondaryEffect"] = (int)m_SecondaryEffect; -} - - - - - void cBeaconEntity::SendTo(cClientHandle & a_Client) { a_Client.SendUpdateBlockEntity(*this); -- cgit v1.2.3 From 856764dee8f0c66397669e8c7c013c758f1d2c81 Mon Sep 17 00:00:00 2001 From: Steven Riehl Date: Sat, 11 Oct 2014 20:39:55 -0600 Subject: convert old style casts to fix warnings --- src/BlockEntities/BeaconEntity.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 02f45a097..de23f7e79 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -227,9 +227,9 @@ void cBeaconEntity::GiveEffects(void) virtual bool Item(cPlayer * a_Player) { Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); - if (PlayerPosition.y > (double)m_PosY) + if (PlayerPosition.y > static_cast(m_PosY)) { - PlayerPosition.y = (double)m_PosY; + PlayerPosition.y = static_cast(m_PosY); } // TODO: Vanilla minecraft uses an AABB check instead of a radius one @@ -255,7 +255,7 @@ void cBeaconEntity::GiveEffects(void) , m_PrimaryEffect(a_PrimaryEffect) , m_SecondaryEffect(a_SecondaryEffect) , m_EffectLevel(a_EffectLevel) - {}; + {} } PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel); GetWorld()->ForEachPlayer(PlayerCallback); @@ -288,7 +288,7 @@ void cBeaconEntity::UsedBy(cPlayer * a_Player) OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this)); Window = GetWindow(); } - + if (Window != NULL) { // if (a_Player->GetWindow() != Window) @@ -307,7 +307,3 @@ void cBeaconEntity::SendTo(cClientHandle & a_Client) { a_Client.SendUpdateBlockEntity(*this); } - - - - -- cgit v1.2.3 From dfd4e15ecb50621f6577c498113a463a7586b104 Mon Sep 17 00:00:00 2001 From: Steven Riehl Date: Sat, 11 Oct 2014 21:18:57 -0600 Subject: refactor an if block to std::min --- src/BlockEntities/BeaconEntity.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index de23f7e79..c744d12f4 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -227,10 +227,7 @@ void cBeaconEntity::GiveEffects(void) virtual bool Item(cPlayer * a_Player) { Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); - if (PlayerPosition.y > static_cast(m_PosY)) - { - PlayerPosition.y = static_cast(m_PosY); - } + PlayerPosition.y = std::min(m_PosY, static_cast(PlayerPosition.y)) // TODO: Vanilla minecraft uses an AABB check instead of a radius one Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ); -- cgit v1.2.3 From 4a257603632c10f491e4c2faa2b297ac63be9dfc Mon Sep 17 00:00:00 2001 From: Steven Riehl Date: Sat, 11 Oct 2014 21:36:40 -0600 Subject: fix std:min call, include algorithm and compare same type --- src/BlockEntities/BeaconEntity.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index c744d12f4..bcd7878a0 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -5,7 +5,7 @@ #include "../BlockArea.h" #include "../Entities/Player.h" - +#include @@ -227,7 +227,7 @@ void cBeaconEntity::GiveEffects(void) virtual bool Item(cPlayer * a_Player) { Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); - PlayerPosition.y = std::min(m_PosY, static_cast(PlayerPosition.y)) + PlayerPosition.y = std::min(static_cast(m_PosY), static_cast(PlayerPosition.y)); // TODO: Vanilla minecraft uses an AABB check instead of a radius one Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ); -- cgit v1.2.3 From a26541a7c3ced0569098edd0aae61c097c2912f4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 20 Oct 2014 21:55:07 +0100 Subject: En masse NULL -> nullptr replace --- src/BlockEntities/BeaconEntity.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/BlockEntities/BeaconEntity.cpp') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index fe5bcf143..85819446c 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -2,7 +2,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "BeaconEntity.h" -#include #include "../BlockArea.h" #include "../Entities/Player.h" @@ -98,7 +97,7 @@ bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect) m_PrimaryEffect = a_Effect; // Send window update: - if (GetWindow() != NULL) + if (GetWindow() != nullptr) { GetWindow()->SetProperty(1, m_PrimaryEffect); } @@ -120,7 +119,7 @@ bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect) m_SecondaryEffect = a_Effect; // Send window update: - if (GetWindow() != NULL) + if (GetWindow() != nullptr) { GetWindow()->SetProperty(2, m_SecondaryEffect); } @@ -185,7 +184,7 @@ void cBeaconEntity::UpdateBeacon(void) if (m_BeaconLevel != OldBeaconLevel) { // Send window update: - if (GetWindow() != NULL) + if (GetWindow() != nullptr) { GetWindow()->SetProperty(0, m_BeaconLevel); } @@ -228,7 +227,10 @@ void cBeaconEntity::GiveEffects(void) virtual bool Item(cPlayer * a_Player) { Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); - PlayerPosition.y = std::min(static_cast(m_PosY), PlayerPosition.y); + if (PlayerPosition.y > (double)m_PosY) + { + PlayerPosition.y = (double)m_PosY; + } // TODO: Vanilla minecraft uses an AABB check instead of a radius one Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ); @@ -253,7 +255,7 @@ void cBeaconEntity::GiveEffects(void) , m_PrimaryEffect(a_PrimaryEffect) , m_SecondaryEffect(a_SecondaryEffect) , m_EffectLevel(a_EffectLevel) - {} + {}; } PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel); GetWorld()->ForEachPlayer(PlayerCallback); @@ -281,13 +283,13 @@ bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk) void cBeaconEntity::UsedBy(cPlayer * a_Player) { cWindow * Window = GetWindow(); - if (Window == NULL) + if (Window == nullptr) { OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this)); Window = GetWindow(); } - - if (Window != NULL) + + if (Window != nullptr) { // if (a_Player->GetWindow() != Window) // -> Because mojang doesn't send a 'close window' packet when you click the cancel button in the beacon inventory ... @@ -305,3 +307,7 @@ void cBeaconEntity::SendTo(cClientHandle & a_Client) { a_Client.SendUpdateBlockEntity(*this); } + + + + -- cgit v1.2.3