diff options
author | Daniel O'Brien <marmot.daniel@gmail.com> | 2013-11-15 08:25:20 +0100 |
---|---|---|
committer | Daniel O'Brien <marmot.daniel@gmail.com> | 2013-11-15 08:25:20 +0100 |
commit | af17faac45f8ecbfc3af64231b65d66872af3301 (patch) | |
tree | a8864aef4d4a9036249170602164927b9ca99d58 /source/BlockEntities/SignEntity.cpp | |
parent | cProtocol add SendExperience() and debugging (diff) | |
parent | Merge pull request #349 from SamJBarney/master (diff) | |
download | cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.gz cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.bz2 cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.lz cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.xz cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.tar.zst cuberite-af17faac45f8ecbfc3af64231b65d66872af3301.zip |
Diffstat (limited to 'source/BlockEntities/SignEntity.cpp')
-rw-r--r-- | source/BlockEntities/SignEntity.cpp | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/source/BlockEntities/SignEntity.cpp b/source/BlockEntities/SignEntity.cpp index 2c160e603..8b335651d 100644 --- a/source/BlockEntities/SignEntity.cpp +++ b/source/BlockEntities/SignEntity.cpp @@ -1,21 +1,19 @@ -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules +// SignEntity.cpp -#include "SignEntity.h" - -#include "../Entities/Player.h" -// #include "ClientHandle.h" -// #include "World.h" -// #include "Root.h" +// Implements the cSignEntity class representing a single sign in the world +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include <json/json.h> +#include "SignEntity.h" +#include "../Entities/Player.h" -cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World) - : cBlockEntity(a_BlockType, a_X, a_Y, a_Z, a_World) +cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ) : + super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, NULL) { } @@ -23,7 +21,8 @@ cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorl -cSignEntity::~cSignEntity() +cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World) : + super(a_BlockType, a_X, a_Y, a_Z, a_World) { } @@ -32,16 +31,16 @@ cSignEntity::~cSignEntity() // It don't do anything when 'used' -void cSignEntity::UsedBy( cPlayer * a_Player ) +void cSignEntity::UsedBy(cPlayer * a_Player) { - (void)a_Player; + UNUSED(a_Player); } -void cSignEntity::SetLines( const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 ) +void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) { m_Line[0] = a_Line1; m_Line[1] = a_Line2; @@ -53,25 +52,28 @@ void cSignEntity::SetLines( const AString & a_Line1, const AString & a_Line2, co -void cSignEntity::SetLine( int a_Index, const AString & a_Line ) +void cSignEntity::SetLine(int a_Index, const AString & a_Line) { - if( a_Index < 4 && a_Index > -1 ) + if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line))) { - m_Line[a_Index] = a_Line; + LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str()); + return; } + m_Line[a_Index] = a_Line; } -AString cSignEntity::GetLine( int a_Index ) const +AString cSignEntity::GetLine(int a_Index) const { - if( a_Index < 4 && a_Index > -1 ) + if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line))) { - return m_Line[a_Index]; + LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index); + return ""; } - return ""; + return m_Line[a_Index]; } @@ -87,19 +89,7 @@ void cSignEntity::SendTo(cClientHandle & a_Client) -#define READ(File, Var) \ - if (File.Read(&Var, sizeof(Var)) != sizeof(Var)) \ - { \ - LOGERROR("ERROR READING cSignEntity %s FROM FILE (line %d)", #Var, __LINE__); \ - return false; \ - } - - - - - - -bool cSignEntity::LoadFromJson( const Json::Value & a_Value ) +bool cSignEntity::LoadFromJson(const Json::Value & a_Value) { m_PosX = a_Value.get("x", 0).asInt(); m_PosY = a_Value.get("y", 0).asInt(); @@ -113,7 +103,11 @@ bool cSignEntity::LoadFromJson( const Json::Value & a_Value ) return true; } -void cSignEntity::SaveToJson( Json::Value & a_Value ) + + + + +void cSignEntity::SaveToJson(Json::Value & a_Value) { a_Value["x"] = m_PosX; a_Value["y"] = m_PosY; |