43
43
#include " Registry.hpp"
44
44
45
45
void ClientCommandHandler::sendPlayerInvUpdate () {
46
- sf ::Packet invPacket;
46
+ Network ::Packet invPacket;
47
47
invPacket << Network::Command::PlayerInvUpdate;
48
48
// FIXME: Sending client id shouldn't be necessary
49
49
invPacket << m_client.id ();
@@ -52,7 +52,7 @@ void ClientCommandHandler::sendPlayerInvUpdate() {
52
52
}
53
53
54
54
void ClientCommandHandler::sendPlayerPosUpdate () {
55
- sf ::Packet packet;
55
+ Network ::Packet packet;
56
56
packet << Network::Command::PlayerPosUpdate;
57
57
// FIXME: Sending client id shouldn't be necessary
58
58
packet << m_client.id ();
@@ -64,7 +64,7 @@ void ClientCommandHandler::sendPlayerPosUpdate() {
64
64
}
65
65
66
66
void ClientCommandHandler::sendPlayerDigBlock (const glm::ivec4 &selectedBlock) {
67
- sf ::Packet packet;
67
+ Network ::Packet packet;
68
68
packet << Network::Command::PlayerDigBlock
69
69
<< s32 (selectedBlock.x )
70
70
<< s32 (selectedBlock.y )
@@ -73,27 +73,27 @@ void ClientCommandHandler::sendPlayerDigBlock(const glm::ivec4 &selectedBlock) {
73
73
}
74
74
75
75
void ClientCommandHandler::sendPlayerPlaceBlock (s32 x, s32 y, s32 z, u32 block) {
76
- sf ::Packet packet;
76
+ Network ::Packet packet;
77
77
packet << Network::Command::PlayerPlaceBlock << x << y << z << block;
78
78
m_client.send (packet);
79
79
}
80
80
81
81
void ClientCommandHandler::sendPlayerInventoryRequest () {
82
- sf ::Packet packet;
82
+ Network ::Packet packet;
83
83
packet << Network::Command::PlayerInventory
84
84
<< u16 (Config::screenWidth) << u16 (Config::screenHeight) << u8 (Config::guiScale);
85
85
m_client.send (packet);
86
86
}
87
87
88
88
void ClientCommandHandler::sendPlayerCreativeWindowRequest () {
89
- sf ::Packet packet;
89
+ Network ::Packet packet;
90
90
packet << Network::Command::PlayerCreativeWindow
91
91
<< u16 (Config::screenWidth) << u16 (Config::screenHeight) << u8 (Config::guiScale);
92
92
m_client.send (packet);
93
93
}
94
94
95
95
void ClientCommandHandler::sendBlockActivated (const glm::ivec4 &selectedBlock) {
96
- sf ::Packet packet;
96
+ Network ::Packet packet;
97
97
packet << Network::Command::BlockActivated
98
98
<< s32 (selectedBlock.x )
99
99
<< s32 (selectedBlock.y )
@@ -103,22 +103,22 @@ void ClientCommandHandler::sendBlockActivated(const glm::ivec4 &selectedBlock) {
103
103
}
104
104
105
105
void ClientCommandHandler::sendBlockInvUpdate (Inventory &inventory) {
106
- sf ::Packet packet;
106
+ Network ::Packet packet;
107
107
packet << Network::Command::BlockInvUpdate;
108
108
packet << s32 (inventory.blockPos ().x ) << s32 (inventory.blockPos ().y ) << s32 (inventory.blockPos ().z );
109
109
packet << inventory;
110
110
m_client.send (packet);
111
111
}
112
112
113
113
void ClientCommandHandler::sendChunkRequest (s32 chunkX, s32 chunkY, s32 chunkZ) {
114
- sf ::Packet packet;
114
+ Network ::Packet packet;
115
115
packet << Network::Command::ChunkRequest;
116
116
packet << chunkX << chunkY << chunkZ;
117
117
m_client.send (packet);
118
118
}
119
119
120
120
void ClientCommandHandler::sendChatMessage (const std::string &message) {
121
- sf ::Packet packet;
121
+ Network ::Packet packet;
122
122
packet << Network::Command::ChatMessage;
123
123
// FIXME: Sending client id shouldn't be necessary
124
124
packet << m_client.id ();
@@ -127,7 +127,7 @@ void ClientCommandHandler::sendChatMessage(const std::string &message) {
127
127
}
128
128
129
129
void ClientCommandHandler::setupCallbacks () {
130
- m_client.setCommandCallback (Network::Command::ClientDisconnect, [this ](sf ::Packet &packet) {
130
+ m_client.setCommandCallback (Network::Command::ClientDisconnect, [this ](Network ::Packet &packet) {
131
131
u16 clientID;
132
132
packet >> clientID;
133
133
@@ -136,27 +136,27 @@ void ClientCommandHandler::setupCallbacks() {
136
136
m_playerBoxes.erase (it);
137
137
});
138
138
139
- m_client.setCommandCallback (Network::Command::RegistryData, [this ](sf ::Packet &packet) {
139
+ m_client.setCommandCallback (Network::Command::RegistryData, [this ](Network ::Packet &packet) {
140
140
// FIXME: This is a quick fix for concurrency between client and server in singleplayer
141
141
if (!m_isSingleplayer)
142
142
Registry::getInstance ().deserialize (packet);
143
143
144
144
m_isRegistryInitialized = true ;
145
145
});
146
146
147
- m_client.setCommandCallback (Network::Command::ChunkData, [this ](sf ::Packet &packet) {
147
+ m_client.setCommandCallback (Network::Command::ChunkData, [this ](Network ::Packet &packet) {
148
148
m_world.receiveChunkData (packet);
149
149
});
150
150
151
- m_client.setCommandCallback (Network::Command::BlockUpdate, [this ](sf ::Packet &packet) {
151
+ m_client.setCommandCallback (Network::Command::BlockUpdate, [this ](Network ::Packet &packet) {
152
152
s32 x, y, z;
153
153
u32 block;
154
154
packet >> x >> y >> z >> block;
155
155
m_world.setBlock (x, y, z, block);
156
156
m_world.setData (x, y, z, block >> 16 );
157
157
});
158
158
159
- m_client.setCommandCallback (Network::Command::PlayerInvUpdate, [this ](sf ::Packet &packet) {
159
+ m_client.setCommandCallback (Network::Command::PlayerInvUpdate, [this ](Network ::Packet &packet) {
160
160
u16 clientId;
161
161
packet >> clientId;
162
162
@@ -166,7 +166,7 @@ void ClientCommandHandler::setupCallbacks() {
166
166
packet >> m_playerBoxes.at (clientId).inventory ();
167
167
});
168
168
169
- m_client.setCommandCallback (Network::Command::PlayerPosUpdate, [this ](sf ::Packet &packet) {
169
+ m_client.setCommandCallback (Network::Command::PlayerPosUpdate, [this ](Network ::Packet &packet) {
170
170
double x, y, z;
171
171
u16 clientId;
172
172
bool isTeleportation;
@@ -184,7 +184,7 @@ void ClientCommandHandler::setupCallbacks() {
184
184
}
185
185
});
186
186
187
- m_client.setCommandCallback (Network::Command::PlayerSpawn, [this ](sf ::Packet &packet) {
187
+ m_client.setCommandCallback (Network::Command::PlayerSpawn, [this ](Network ::Packet &packet) {
188
188
u16 clientId;
189
189
gk::Vector3d pos;
190
190
packet >> clientId >> pos.x >> pos.y >> pos.z ;
@@ -199,7 +199,7 @@ void ClientCommandHandler::setupCallbacks() {
199
199
}
200
200
});
201
201
202
- m_client.setCommandCallback (Network::Command::PlayerChangeDimension, [this ](sf ::Packet &packet) {
202
+ m_client.setCommandCallback (Network::Command::PlayerChangeDimension, [this ](Network ::Packet &packet) {
203
203
u16 clientId, dimension;
204
204
s32 x, y, z;
205
205
packet >> clientId >> x >> y >> z >> dimension;
@@ -213,11 +213,11 @@ void ClientCommandHandler::setupCallbacks() {
213
213
}
214
214
});
215
215
216
- m_client.setCommandCallback (Network::Command::BlockGUIData, [this ](sf ::Packet &packet) {
216
+ m_client.setCommandCallback (Network::Command::BlockGUIData, [this ](Network ::Packet &packet) {
217
217
gk::ApplicationStateStack::getInstance ().push <LuaGUIState>(*this , m_player, m_world, packet, &gk::ApplicationStateStack::getInstance ().top ());
218
218
});
219
219
220
- m_client.setCommandCallback (Network::Command::BlockInvUpdate, [this ](sf ::Packet &packet) {
220
+ m_client.setCommandCallback (Network::Command::BlockInvUpdate, [this ](Network ::Packet &packet) {
221
221
gk::Vector3<s32> pos;
222
222
packet >> pos.x >> pos.y >> pos.z ;
223
223
@@ -229,7 +229,7 @@ void ClientCommandHandler::setupCallbacks() {
229
229
packet >> data->inventory ;
230
230
});
231
231
232
- m_client.setCommandCallback (Network::Command::BlockDataUpdate, [this ](sf ::Packet &packet) {
232
+ m_client.setCommandCallback (Network::Command::BlockDataUpdate, [this ](Network ::Packet &packet) {
233
233
gk::Vector3<s32> pos;
234
234
packet >> pos.x >> pos.y >> pos.z ;
235
235
@@ -251,7 +251,7 @@ void ClientCommandHandler::setupCallbacks() {
251
251
}
252
252
});
253
253
254
- m_client.setCommandCallback (Network::Command::EntitySpawn, [this ](sf ::Packet &packet) {
254
+ m_client.setCommandCallback (Network::Command::EntitySpawn, [this ](Network ::Packet &packet) {
255
255
entt::entity entityID;
256
256
packet >> entityID;
257
257
@@ -268,7 +268,7 @@ void ClientCommandHandler::setupCallbacks() {
268
268
}
269
269
});
270
270
271
- m_client.setCommandCallback (Network::Command::EntityDespawn, [this ](sf ::Packet &packet) {
271
+ m_client.setCommandCallback (Network::Command::EntityDespawn, [this ](Network ::Packet &packet) {
272
272
entt::entity entityID;
273
273
packet >> entityID;
274
274
@@ -280,7 +280,7 @@ void ClientCommandHandler::setupCallbacks() {
280
280
gkError () << " EntityDespawn: Entity ID" << std::underlying_type_t <entt::entity>(entityID) << " is invalid" ;
281
281
});
282
282
283
- m_client.setCommandCallback (Network::Command::EntityPosition, [this ](sf ::Packet &packet) {
283
+ m_client.setCommandCallback (Network::Command::EntityPosition, [this ](Network ::Packet &packet) {
284
284
entt::entity entityID;
285
285
packet >> entityID;
286
286
@@ -293,7 +293,7 @@ void ClientCommandHandler::setupCallbacks() {
293
293
gkError () << " EntityPosition: Entity ID" << std::underlying_type_t <entt::entity>(entityID) << " is invalid" ;
294
294
});
295
295
296
- m_client.setCommandCallback (Network::Command::EntityRotation, [this ](sf ::Packet &packet) {
296
+ m_client.setCommandCallback (Network::Command::EntityRotation, [this ](Network ::Packet &packet) {
297
297
entt::entity entityID;
298
298
packet >> entityID;
299
299
@@ -309,7 +309,7 @@ void ClientCommandHandler::setupCallbacks() {
309
309
gkError () << " EntityRotation: Entity ID" << std::underlying_type_t <entt::entity>(entityID) << " is invalid" ;
310
310
});
311
311
312
- m_client.setCommandCallback (Network::Command::EntityAnimation, [this ](sf ::Packet &packet) {
312
+ m_client.setCommandCallback (Network::Command::EntityAnimation, [this ](Network ::Packet &packet) {
313
313
entt::entity entityID;
314
314
packet >> entityID;
315
315
@@ -322,7 +322,7 @@ void ClientCommandHandler::setupCallbacks() {
322
322
gkError () << " EntityAnimation: Entity ID" << std::underlying_type_t <entt::entity>(entityID) << " is invalid" ;
323
323
});
324
324
325
- m_client.setCommandCallback (Network::Command::EntityDrawableDef, [this ](sf ::Packet &packet) {
325
+ m_client.setCommandCallback (Network::Command::EntityDrawableDef, [this ](Network ::Packet &packet) {
326
326
entt::entity entityID;
327
327
packet >> entityID;
328
328
0 commit comments