diff options
author | Elisey Puzko <puzko.e02@gmail.com> | 2018-02-22 20:27:43 +0100 |
---|---|---|
committer | Elisey Puzko <puzko.e02@gmail.com> | 2018-02-22 20:27:43 +0100 |
commit | 083eef7a50a223bd5993ca4715e6ada42bbca3a0 (patch) | |
tree | 2fa3176f5353563cf740463b62158a832cc057bd /src/GameState.cpp | |
parent | Bare-bones blocks placement (diff) | |
download | AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.tar AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.tar.gz AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.tar.bz2 AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.tar.lz AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.tar.xz AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.tar.zst AltCraft-083eef7a50a223bd5993ca4715e6ada42bbca3a0.zip |
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r-- | src/GameState.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index b963ef0..743a750 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -7,11 +7,11 @@ #include "Packet.hpp" void GameState::Update(float deltaTime) { - if (g_IsGameStarted) { - std::chrono::steady_clock clock; - static auto timeOfPreviousSendedPacket(clock.now()); + if (g_IsGameStarted) { + std::chrono::steady_clock clock; + static auto timeOfPreviousSendedPacket(clock.now()); auto delta = clock.now() - timeOfPreviousSendedPacket; - using namespace std::chrono_literals; + using namespace std::chrono_literals; if (delta >= 50ms) { auto packetToSend = std::make_shared<PacketPlayerPositionAndLookSB>( player->pos.x, player->pos.y, player->pos.z, @@ -58,7 +58,7 @@ void GameState::Update(float deltaTime) { isBlockSelected = raycast.isHit; raycastHit = raycast.hitPos; - } + } } void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) { @@ -559,6 +559,9 @@ glm::mat4 GameState::GetViewMatrix() { // send_packet(packet_type=start_digging_packet) // delay(time=selected_block_dig_time, action=finish_digging) void GameState::StartDigging() { + if (!isBlockSelected) + return; + auto packetStart = std::make_shared<PacketPlayerDigging>(0,selectedBlock,1); auto packet = std::static_pointer_cast<Packet>(packetStart); PUSH_EVENT("SendPacket",packet); @@ -584,6 +587,9 @@ void GameState::CancelDigging() { } void GameState::PlaceBlock() { + if (!isBlockSelected) + return; + auto packetPlace = std::make_shared<PacketPlayerBlockPlacement>( selectedBlock, 1, 0, 0.0, 0.0, 0.0); |