diff options
author | sfan5 <sfan5@live.de> | 2019-07-16 14:00:42 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-08-10 19:44:27 +0200 |
commit | cf64054390970f3cf974afb2b174340a3e1da382 (patch) | |
tree | 9f3a62d3f935ae76f00fb1c0002f9ba59e59f219 /src/network | |
parent | b19400aa74f30ef61ba0c1bb4a25a978e7cf4125 (diff) | |
download | minetest-cf64054390970f3cf974afb2b174340a3e1da382.tar.gz minetest-cf64054390970f3cf974afb2b174340a3e1da382.tar.bz2 minetest-cf64054390970f3cf974afb2b174340a3e1da382.zip |
Implement adding velocity to player from Lua
The intended usecase is knockback, but there's potential for more.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/clientopcodes.cpp | 2 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 11 | ||||
-rw-r--r-- | src/network/networkprotocol.h | 6 | ||||
-rw-r--r-- | src/network/serveropcodes.cpp | 2 |
4 files changed, 19 insertions, 2 deletions
diff --git a/src/network/clientopcodes.cpp b/src/network/clientopcodes.cpp index 7f3ab50ed..8641cadec 100644 --- a/src/network/clientopcodes.cpp +++ b/src/network/clientopcodes.cpp @@ -67,7 +67,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] = null_command_handler, { "TOCLIENT_TIME_OF_DAY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_TimeOfDay }, // 0x29 { "TOCLIENT_CSM_RESTRICTION_FLAGS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMRestrictionFlags }, // 0x2A - null_command_handler, + { "TOCLIENT_PLAYER_SPEED", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_PlayerSpeed }, // 0x2B null_command_handler, null_command_handler, null_command_handler, diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 1ae47d190..520fcfa81 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1383,6 +1383,17 @@ void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt) loadMods(); } +void Client::handleCommand_PlayerSpeed(NetworkPacket *pkt) +{ + v3f added_vel; + + *pkt >> added_vel; + + LocalPlayer *player = m_env.getLocalPlayer(); + assert(player != NULL); + player->addVelocity(added_vel); +} + /* * Mod channels */ diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 0ab11ee7e..451518bbf 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -194,6 +194,7 @@ with this program; if not, write to the Free Software Foundation, Inc., New network float format ContentFeatures version 13 Add full Euler rotations instead of just yaw + Add TOCLIENT_PLAYER_SPEED */ #define LATEST_PROTOCOL_VERSION 37 @@ -295,6 +296,11 @@ enum ToClientCommand u32 CSMRestrictionFlags byteflag */ + TOCLIENT_PLAYER_SPEED = 0x2B, + /* + v3f added_vel + */ + // (oops, there is some gap here) TOCLIENT_CHAT_MESSAGE = 0x2F, diff --git a/src/network/serveropcodes.cpp b/src/network/serveropcodes.cpp index 013b549c6..8c5579a36 100644 --- a/src/network/serveropcodes.cpp +++ b/src/network/serveropcodes.cpp @@ -156,7 +156,7 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] = null_command_factory, { "TOCLIENT_TIME_OF_DAY", 0, true }, // 0x29 { "TOCLIENT_CSM_RESTRICTION_FLAGS", 0, true }, // 0x2A - null_command_factory, + { "TOCLIENT_PLAYER_SPEED", 0, true }, // 0x2B null_command_factory, null_command_factory, null_command_factory, |