aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorAndrew Ward <rw@rubenwardy.com>2018-03-28 16:04:41 +0100
committerGitHub <noreply@github.com>2018-03-28 16:04:41 +0100
commit2323842dd3dd336b087ca3cf9756e0680b3a1244 (patch)
tree6b76f139e42872c8457c991925a5a2e6d41b85c9 /src/network
parent040b878cd5f77f6b44622b7c00255b4981500dc8 (diff)
downloadminetest-2323842dd3dd336b087ca3cf9756e0680b3a1244.tar.gz
minetest-2323842dd3dd336b087ca3cf9756e0680b3a1244.tar.bz2
minetest-2323842dd3dd336b087ca3cf9756e0680b3a1244.zip
Add formspec theming using prepended strings
Diffstat (limited to 'src/network')
-rw-r--r--src/network/clientopcodes.cpp1
-rw-r--r--src/network/clientpackethandler.cpp9
-rw-r--r--src/network/networkprotocol.h10
-rw-r--r--src/network/serveropcodes.cpp1
4 files changed, 19 insertions, 2 deletions
diff --git a/src/network/clientopcodes.cpp b/src/network/clientopcodes.cpp
index 929827529..9962de46a 100644
--- a/src/network/clientopcodes.cpp
+++ b/src/network/clientopcodes.cpp
@@ -121,6 +121,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
null_command_handler,
null_command_handler,
{ "TOCLIENT_SRP_BYTES_S_B", TOCLIENT_STATE_NOT_CONNECTED, &Client::handleCommand_SrpBytesSandB }, // 0x60
+ { "TOCLIENT_FORMSPEC_PREPEND", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_FormspecPrepend }, // 0x61,
};
const static ServerCommandFactory null_command_factory = { "TOSERVER_NULL", 0, false };
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 37b649364..bc1f18ae8 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -1324,6 +1324,15 @@ void Client::handleCommand_SrpBytesSandB(NetworkPacket* pkt)
Send(&resp_pkt);
}
+void Client::handleCommand_FormspecPrepend(NetworkPacket *pkt)
+{
+ LocalPlayer *player = m_env.getLocalPlayer();
+ assert(player != NULL);
+
+ // Store formspec in LocalPlayer
+ *pkt >> player->formspec_prepend;
+}
+
void Client::handleCommand_CSMFlavourLimits(NetworkPacket *pkt)
{
*pkt >> m_csm_flavour_limits >> m_csm_noderange_limit;
diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h
index 53d36e666..0a5701e59 100644
--- a/src/network/networkprotocol.h
+++ b/src/network/networkprotocol.h
@@ -187,6 +187,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
'zoom_fov'.
Nodebox version 5
Add disconnected nodeboxes
+ Add TOCLIENT_FORMSPEC_PREPEND
*/
#define LATEST_PROTOCOL_VERSION 36
@@ -644,7 +645,13 @@ enum ToClientCommand
std::string bytes_B
*/
- TOCLIENT_NUM_MSG_TYPES = 0x61,
+ TOCLIENT_FORMSPEC_PREPEND = 0x61,
+ /*
+ u16 len
+ u8[len] formspec
+ */
+
+ TOCLIENT_NUM_MSG_TYPES = 0x62,
};
enum ToServerCommand
@@ -930,4 +937,3 @@ enum CSMFlavourLimit : u64 {
CSM_FL_LOOKUP_NODES = 0x00000010, // Limit node lookups
CSM_FL_ALL = 0xFFFFFFFF,
};
-
diff --git a/src/network/serveropcodes.cpp b/src/network/serveropcodes.cpp
index 6dcf9c93a..883ff9d10 100644
--- a/src/network/serveropcodes.cpp
+++ b/src/network/serveropcodes.cpp
@@ -210,4 +210,5 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
null_command_factory,
null_command_factory,
{ "TOSERVER_SRP_BYTES_S_B", 0, true }, // 0x60
+ { "TOCLIENT_FORMSPEC_PREPEND", 0, true }, // 0x61
};