2012-06-14 09:06:06 -04:00
|
|
|
|
2013-11-14 09:37:09 -05:00
|
|
|
// SignEntity.cpp
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-11-14 09:37:09 -05:00
|
|
|
// Implements the cSignEntity class representing a single sign in the world
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-11-14 09:37:09 -05:00
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
2014-09-26 13:13:19 -04:00
|
|
|
#include "json/value.h"
|
2013-11-14 09:37:09 -05:00
|
|
|
#include "SignEntity.h"
|
2014-09-26 13:13:19 -04:00
|
|
|
#include "../ClientHandle.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-29 08:59:24 -04:00
|
|
|
cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World):
|
|
|
|
super(a_BlockType, a_BlockMeta, a_Pos, a_World)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2017-06-15 09:32:33 -04:00
|
|
|
ASSERT((a_BlockType == E_BLOCK_WALLSIGN) || (a_BlockType == E_BLOCK_SIGN_POST));
|
2019-09-29 08:59:24 -04:00
|
|
|
ASSERT(cChunkDef::IsValidHeight(a_Pos.y));
|
2017-06-15 09:32:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cSignEntity::CopyFrom(const cBlockEntity & a_Src)
|
|
|
|
{
|
2019-09-29 08:59:24 -04:00
|
|
|
super::CopyFrom(a_Src);
|
2018-05-02 03:50:36 -04:00
|
|
|
auto & src = static_cast<const cSignEntity &>(a_Src);
|
2017-06-15 09:32:33 -04:00
|
|
|
for (size_t i = 0; i < ARRAYCOUNT(m_Line); ++i)
|
|
|
|
{
|
|
|
|
m_Line[i] = src.m_Line[i];
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-12-01 17:12:44 -05:00
|
|
|
bool cSignEntity::UsedBy(cPlayer * a_Player)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-11-14 09:37:09 -05:00
|
|
|
UNUSED(a_Player);
|
2015-12-01 17:12:44 -05:00
|
|
|
return true;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-14 09:37:09 -05:00
|
|
|
void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
m_Line[0] = a_Line1;
|
|
|
|
m_Line[1] = a_Line2;
|
|
|
|
m_Line[2] = a_Line3;
|
|
|
|
m_Line[3] = a_Line4;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-14 09:37:09 -05:00
|
|
|
void cSignEntity::SetLine(int a_Index, const AString & a_Line)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-10-11 22:39:55 -04:00
|
|
|
if ((a_Index < 0) || (a_Index >= static_cast<int>(ARRAYCOUNT(m_Line))))
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-11-14 09:37:09 -05:00
|
|
|
LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str());
|
|
|
|
return;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2013-11-14 09:37:09 -05:00
|
|
|
m_Line[a_Index] = a_Line;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-14 09:37:09 -05:00
|
|
|
AString cSignEntity::GetLine(int a_Index) const
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-10-11 22:39:55 -04:00
|
|
|
if ((a_Index < 0) || (a_Index >= static_cast<int>(ARRAYCOUNT(m_Line))))
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-11-14 09:37:09 -05:00
|
|
|
LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index);
|
|
|
|
return "";
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2013-11-14 09:37:09 -05:00
|
|
|
return m_Line[a_Index];
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-24 03:58:26 -04:00
|
|
|
void cSignEntity::SendTo(cClientHandle & a_Client)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2019-09-29 08:59:24 -04:00
|
|
|
a_Client.SendUpdateSign(m_Pos.x, m_Pos.y, m_Pos.z, m_Line[0], m_Line[1], m_Line[2], m_Line[3]);
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|