summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/CommandBlockEntity.cpp
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-01-18 15:59:33 +0100
committerandrew <xdotftw@gmail.com>2014-01-18 15:59:33 +0100
commit1ad6469a180dfe6932c756fe3c99bcada3ee0b7e (patch)
treef6a13924ef4972cd89e5ba4a8fb1e7363b6ba92b /src/BlockEntities/CommandBlockEntity.cpp
parentCommand block (de)serialization (diff)
downloadcuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.tar
cuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.tar.gz
cuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.tar.bz2
cuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.tar.lz
cuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.tar.xz
cuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.tar.zst
cuberite-1ad6469a180dfe6932c756fe3c99bcada3ee0b7e.zip
Diffstat (limited to 'src/BlockEntities/CommandBlockEntity.cpp')
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index 88e55dece..e70e259aa 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -8,6 +8,10 @@
#include "CommandBlockEntity.h"
#include "../Entities/Player.h"
+#include "CommandOutput.h"
+#include "Root.h"
+#include "Server.h" // ExecuteConsoleCommand()
+
@@ -45,7 +49,8 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
cWindow * Window = GetWindow();
if (Window == NULL)
{
- //OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); FIXME
+ // TODO 2014-01-18 xdot: Open the appropriate window.
+ // OpenWindow(new cCommandBlockWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
}
@@ -64,7 +69,7 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
{
- m_Command = a_Cmd;LOGD("Hrey %s", a_Cmd.c_str());
+ m_Command = a_Cmd;
}
@@ -190,11 +195,28 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value)
void cCommandBlockEntity::Execute()
{
- // TODO: Parse arguments and dispatch command
+ class CommandBlockOutCb :
+ public cCommandOutputCallback
+ {
+ cCommandBlockEntity* m_CmdBlock;
+
+ public:
+ CommandBlockOutCb(cCommandBlockEntity* a_CmdBlock) : m_CmdBlock(a_CmdBlock) {}
+
+ virtual void Out(const AString & a_Text)
+ {
+ ASSERT(m_CmdBlock != NULL);
+
+ // Overwrite field
+ m_CmdBlock->SetLastOutput(a_Text);
+ }
+ } CmdBlockOutCb(this);
+
+ cServer* Server = cRoot::Get()->GetServer();
- LOGD("Command: %s", m_Command.c_str());
+ Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
- m_LastOutput = "";
+ // TODO 2014-01-18 xdot: Update the signal strength.
m_Result = 0;
}