Skip to content

Commit

Permalink
[LuaGUIState] Small fix. [ServerWorld|ServerChunk] Fixed BlockData po…
Browse files Browse the repository at this point in the history
…sition sending.
  • Loading branch information
Unarelith committed Feb 8, 2020
1 parent 442bafc commit 5ffbfe0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion client/include/states/LuaGUIState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
class ClientPlayer;
class ClientWorld;

// FIXME: This class is almost a duplicate of InventoryState
class LuaGUIState : public InterfaceState {
public:
LuaGUIState(ClientCommandHandler &client, ClientPlayer &player, ClientWorld &world, sf::Packet &packet, gk::ApplicationState *parent = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion client/source/states/LuaGUIState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void LuaGUIState::update() {
currentItemWidget = it.currentItemWidget();
}

if (m_widgets.size() != 1) // FIXME
if (m_inventoryWidgets.size() != 0) // FIXME
m_mouseItemWidget.update(currentItemWidget);
}

Expand Down
2 changes: 1 addition & 1 deletion server/source/world/ServerChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void ServerChunk::updateLights() {

void ServerChunk::onBlockPlaced(int x, int y, int z, const Block &block) const {
const ServerBlock &serverBlock = (ServerBlock &)block;
serverBlock.onBlockPlaced(glm::ivec3{x, y, z}, m_world);
serverBlock.onBlockPlaced(glm::ivec3{x + m_x * CHUNK_WIDTH, y + m_y * CHUNK_HEIGHT, z + m_z * CHUNK_DEPTH}, m_world);
}

void ServerChunk::tick(std::unordered_map<u16, ServerPlayer> &players, World &world, Server &server) {
Expand Down
8 changes: 6 additions & 2 deletions server/source/world/ServerWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ void ServerWorld::sendChunkData(const Client &client, ServerChunk *chunk) {

BlockData *blockData = chunk->getBlockData(x, y, z);
if (blockData) {
s32 globalX = x + chunk->x() * CHUNK_WIDTH;
s32 globalY = y + chunk->y() * CHUNK_HEIGHT;
s32 globalZ = z + chunk->z() * CHUNK_DEPTH;

sf::Packet packet1;
packet1 << Network::Command::BlockDataUpdate << s32(x) << s32(y) << s32(z);
packet1 << Network::Command::BlockDataUpdate << globalX << globalY << globalZ;
packet1 << blockData->data << blockData->useAltTiles;
client.tcpSocket->send(packet1);

sf::Packet packet2;
packet2 << Network::Command::BlockInvUpdate;
packet2 << s32(x) << s32(y) << s32(z);
packet2 << globalX << globalY << globalZ;
packet2 << blockData->inventory;
client.tcpSocket->send(packet2);
}
Expand Down

0 comments on commit 5ffbfe0

Please sign in to comment.