summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities')
-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;
}