2019-03-17 17:22:53 +01:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* OpenMiner
|
|
|
|
* Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
|
2019-03-17 17:22:53 +01:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2019-03-17 17:22:53 +01:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2019-03-17 17:22:53 +01:00
|
|
|
*
|
2020-02-08 18:34:26 +09:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2019-03-17 17:22:53 +01:00
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef CLIENTCOMMANDHANDLER_HPP_
|
|
|
|
#define CLIENTCOMMANDHANDLER_HPP_
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "PlayerBox.hpp"
|
|
|
|
|
|
|
|
namespace gk {
|
|
|
|
class Camera;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
class ClientPlayer;
|
|
|
|
class ClientWorld;
|
|
|
|
|
|
|
|
class ClientCommandHandler {
|
|
|
|
public:
|
2020-02-15 20:22:10 +09:00
|
|
|
ClientCommandHandler(Client &client, ClientWorld &world, ClientPlayer &player, std::unordered_map<u16, PlayerBox> &playerBoxes)
|
|
|
|
: m_client(client), m_world(world), m_player(player), m_playerBoxes(playerBoxes) {}
|
2019-03-17 17:22:53 +01:00
|
|
|
|
2019-04-08 12:59:02 +02:00
|
|
|
void sendPlayerInvUpdate();
|
2019-04-08 15:29:19 +02:00
|
|
|
void sendPlayerPosUpdate();
|
2020-02-17 18:53:33 +09:00
|
|
|
void sendPlayerDigBlock(const glm::ivec4 &selectedBlock);
|
2019-04-08 12:59:02 +02:00
|
|
|
void sendPlayerPlaceBlock(s32 x, s32 y, s32 z, u32 block);
|
2020-02-08 02:48:39 +09:00
|
|
|
void sendPlayerInventoryRequest();
|
2020-02-17 18:53:33 +09:00
|
|
|
void sendBlockActivated(const glm::ivec4 &selectedBlock);
|
2019-04-08 12:59:02 +02:00
|
|
|
void sendBlockInvUpdate(Inventory &inventory);
|
2020-01-20 13:40:07 +09:00
|
|
|
void sendChunkRequest(s32 chunkX, s32 chunkY, s32 chunkZ);
|
2019-04-08 12:59:02 +02:00
|
|
|
|
2019-03-17 17:22:53 +01:00
|
|
|
void setupCallbacks();
|
|
|
|
|
|
|
|
bool isRegistryInitialized() const { return m_isRegistryInitialized; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Client &m_client;
|
|
|
|
ClientWorld &m_world;
|
|
|
|
ClientPlayer &m_player;
|
|
|
|
|
|
|
|
std::unordered_map<u16, PlayerBox> &m_playerBoxes;
|
|
|
|
|
|
|
|
bool m_isRegistryInitialized = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CLIENTCOMMANDHANDLER_HPP_
|