Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
client.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "clientenvironment.h"
8#include "gamedef.h"
9#include "gameparams.h" // ELoginRegister
10#include "inventorymanager.h"
11#include "irrlichttypes.h"
12#include "network/address.h"
13#include "network/networkprotocol.h" // multiple enums
14#include "network/peerhandler.h"
15#include "util/numeric.h"
16#include "util/string.h" // StringMap
17
18#include <map>
19#include <memory>
20#include <ostream>
21#include <set>
22#include <unordered_set>
23#include <vector>
24
25#if !IS_CLIENT_BUILD
26#error Do not include in server builds
27#endif
28
29#define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f
30
31class Camera;
33class ISoundManager;
37class LuaError;
38class MapDatabase;
40class Minimap;
41class ModChannelMgr;
42class MtEventManager;
43class NetworkPacket;
44class NodeDefManager;
45class ParticleManager;
46class RenderingEngine;
48struct ChatMessage;
50struct ClientEvent;
51struct MapDrawControl;
52struct MapNode;
53struct PlayerControl;
54struct PointedThing;
56
57namespace scene {
58class IAnimatedMesh;
59}
60
61namespace con {
62class IConnection;
63}
64using sound_handle_t = int;
65
71
72/*
73 Packet counter
74*/
75
77{
78public:
79 PacketCounter() = default;
80
81 void add(u16 command)
82 {
83 auto n = m_packets.find(command);
84 if (n == m_packets.end())
85 m_packets[command] = 1;
86 else
87 n->second++;
88 }
89
90 void clear()
91 {
92 m_packets.clear();
93 }
94
95 u32 sum() const;
96 void print(std::ostream &o) const;
97
98private:
99 // command, count
100 std::map<u16, u32> m_packets;
101};
102
103class ClientScripting;
104
105class Client : public con::PeerHandler, public InventoryManager, public IGameDef
106{
107public:
108 /*
109 NOTE: Nothing is thread-safe here.
110 */
111
112 Client(
113 const char *playername,
114 const std::string &password,
115 MapDrawControl &control,
119 NodeDefManager *nodedef,
121 MtEventManager *event,
122 RenderingEngine *rendering_engine,
123 ItemVisualsManager *item_visuals,
124 ELoginRegister allow_login_or_register
125 );
126
127 ~Client();
129
130 // Load local mods into memory
131 void scanModSubfolder(const std::string &mod_name, const std::string &mod_path,
132 std::string mod_subpath);
133 inline void scanModIntoMemory(const std::string &mod_name, const std::string &mod_path)
134 {
135 scanModSubfolder(mod_name, mod_path, "");
136 }
137
138 /*
139 request all threads managed by client to be stopped
140 */
141 void Stop();
142
143
144 bool isShutdown();
145
146 void connect(const Address &address, const std::string &address_name);
147
148 /*
149 Stuff that references the environment is valid only as
150 long as this is not called. (eg. Players)
151 If this throws a PeerNotFoundException, the connection has
152 timed out.
153 */
154 void step(float dtime);
155
156 /*
157 * Command Handlers
158 */
159
160 void handleCommand(NetworkPacket* pkt);
161
224
225 void ProcessData(NetworkPacket *pkt);
226
227 void Send(NetworkPacket* pkt);
228
229 void interact(InteractAction action, const PointedThing &pointed);
230
231 void sendNodemetaFields(v3s16 p, const std::string &formname,
232 const StringMap &fields);
233 void sendInventoryFields(const std::string &formname,
234 const StringMap &fields);
236 void sendChatMessage(const std::wstring &message);
237 void clearOutChatQueue();
238 void sendChangePassword(const std::string &oldpassword,
239 const std::string &newpassword);
240 void sendDamage(u16 damage);
241 void sendRespawnLegacy();
242 void sendReady();
243 void sendHaveMedia(const std::vector<u32> &tokens);
244 void sendUpdateClientInfo(const ClientDynamicInfo &info);
245
249 static const std::string &getBuiltinLuaPath();
250 static const std::string &getClientModsLuaPath();
251
252 const std::vector<ModSpec> &getMods() const override;
253 const ModSpec* getModSpec(const std::string &modname) const override;
254
255 // Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
256 void removeNode(v3s16 p);
257
258 // helpers to enforce CSM restrictions
259 MapNode CSMGetNode(v3s16 p, bool *is_valid_position);
260 int CSMClampRadius(v3s16 pos, int radius);
262
263 void addNode(v3s16 p, MapNode n, bool remove_metadata = true);
264
265 void setPlayerControl(PlayerControl &control);
266
267 // Returns true if the inventory of the local player has been
268 // updated from the server. If it is true, it is set to false.
269 bool updateWieldedItem();
270
271 /* InventoryManager interface */
272 Inventory* getInventory(const InventoryLocation &loc) override;
273 void inventoryAction(InventoryAction *a) override;
274
275 // Send the item number 'item' as player item to the server
276 void setPlayerItem(u16 item);
277
278 const std::set<std::string> &getConnectedPlayerNames()
279 {
280 return m_env.getPlayerNames();
281 }
282
283 float getAnimationTime() const
284 {
285 return m_animation_time;
286 }
287
289 int getCrackLevel();
291 void setCrack(int level, v3s16 pos);
292
293 u16 getHP();
294
295 bool checkPrivilege(const std::string &priv) const
296 { return (m_privileges.count(priv) != 0); }
297
298 const std::unordered_set<std::string> &getPrivilegeList() const
299 { return m_privileges; }
300
301 bool getChatMessage(std::wstring &message);
302 void typeChatMessage(const std::wstring& message);
303
304 u64 getMapSeed() const { return m_map_seed; }
305
306 void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
307 // Including blocks at appropriate edges
308 void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
309 void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);
310
311 bool hasClientEvents() const { return !m_client_event_queue.empty(); }
312 // Get event from queue. If queue is empty, it triggers an assertion failure.
314
315 bool accessDenied() const { return m_access_denied; }
316
318
319 void setFatalError(const std::string &reason)
320 {
321 m_access_denied = true;
322 m_access_denied_reason = reason;
323 }
324 void setFatalError(const LuaError &e);
325
326 // Renaming accessDeniedReason to better name could be good as it's used to
327 // disconnect client when CSM failed.
328 const std::string &accessDeniedReason() const { return m_access_denied_reason; }
329
330 bool itemdefReceived() const
331 { return m_itemdef_received; }
332 bool nodedefReceived() const
333 { return m_nodedef_received; }
334 bool mediaReceived() const
335 { return !m_media_downloader; }
338
339 u16 getProtoVersion() const
340 { return m_proto_ver; }
341
342 // Whether the server is in "simple singleplayer mode".
343 // This implies "m_internal_server = true".
345
346 // Whether the server is hosted by the same Luanti instance and singletons
347 // like g_settings are shared between client and server.
348 //
349 // This is intentionally *not* true if we're just connecting to a localhost
350 // server hosted by a different Luanti instance.
352
353 float mediaReceiveProgress();
354
355 void drawLoadScreen(const std::wstring &text, float dtime, int percent);
357 void showUpdateProgressTexture(void *args, float progress);
358
359 float getRTT();
360 float getCurRate();
361 // has the server ever replied to us, used for connection retry/fallback
362 bool hasServerReplied() const {
363 return getProtoVersion() != 0; // (set in TOCLIENT_HELLO)
364 }
365
366 Minimap* getMinimap() { return m_minimap.get(); }
367 void setCamera(Camera* camera) { m_camera = camera; }
368
369 Camera* getCamera () { return m_camera; }
370 scene::ISceneManager *getSceneManager();
371
372 // IGameDef interface
373 bool isClient() override { return true; }
375 const NodeDefManager* getNodeDefManager() override;
379 u16 allocateUnknownNodeId(const std::string &name) override;
383 bool checkLocalPrivilege(const std::string &priv)
384 { return checkPrivilege(priv); }
385 virtual scene::IAnimatedMesh* getMesh(const std::string &filename, bool cache = false);
386 const std::string* getModFile(std::string filename);
388
390
391 // Migrates away old files-based mod storage if necessary
392 void migrateModStorage();
393
394 // The following set of functions is used by ClientMediaDownloader
395 // Insert a media file appropriately into the appropriate manager
396 bool loadMedia(const std::string &data, const std::string &filename,
397 bool from_media_push = false);
398
399 // Send a request for conventional media transfer
400 void request_media(const std::vector<std::string> &file_requests);
401
403
404 void makeScreenshot();
405
406 inline void pushToChatQueue(ChatMessage *cec)
407 {
408 m_chat_queue.push(cec);
409 }
410
412 bool modsLoaded() const { return m_mods_loaded; }
413
414 void pushToEventQueue(ClientEvent *event);
415
416 // IP and port we're connected to
418
419 // Hostname of the connected server (but can also be a numerical IP)
420 const std::string &getAddressName() const
421 {
422 return m_address_name;
423 }
424
425 inline u64 getCSMRestrictionFlags() const
426 {
428 }
429
431 {
432 return m_csm_restriction_flags & flag;
433 }
434
435 bool joinModChannel(const std::string &channel) override;
436 bool leaveModChannel(const std::string &channel) override;
437 bool sendModChannelMessage(const std::string &channel,
438 const std::string &message) override;
439 ModChannel *getModChannel(const std::string &channel) override;
440
441 const std::string &getFormspecPrepend() const;
442
444 {
445 return m_mesh_grid;
446 }
447
449
450private:
451 void loadMods();
452
453 // Virtual methods from con::PeerHandler
454 void peerAdded(con::IPeer *peer) override;
455 void deletingPeer(con::IPeer *peer, bool timeout) override;
456
457 void initLocalMapSaving(const Address &address, const std::string &hostname);
458
459 void ReceiveAll();
460
461 void sendPlayerPos();
462
463 void deleteAuthData();
464 // helper method shared with clientpackethandler
465 static AuthMechanism choseAuthMech(const u32 mechs);
466
467 void sendInit(const std::string &playerName);
468 void startAuth(AuthMechanism chosen_auth_mechanism);
469 void sendDeletedBlocks(std::vector<v3s16> &blocks);
470 void sendGotBlocks(const std::vector<v3s16> &blocks);
471 void sendRemovedSounds(const std::vector<s32> &soundList);
472
473 bool canSendChatMessage() const;
474
477 float m_avg_rtt_timer = 0.0f;
481
490
491
492 std::unique_ptr<MeshUpdateManager> m_mesh_update_manager;
494 std::unique_ptr<ParticleManager> m_particle_manager;
495 std::unique_ptr<con::IConnection> m_con;
496 std::string m_address_name;
498 Camera *m_camera = nullptr;
499 std::unique_ptr<Minimap> m_minimap;
500
501 // Server serialization version
503
504 // Used version of the protocol with server
505 // If 0, server init hasn't been received yet.
506 u16 m_proto_ver = 0;
507
509 std::unique_ptr<Inventory> m_inventory_from_server;
513 // Block mesh animation parameters
514 float m_animation_time = 0.0f;
517 std::queue<std::wstring> m_out_chat_queue;
520 std::queue<ChatMessage *> m_chat_queue;
521
522 // The authentication methods we can use to enter sudo mode (=change password)
524
525 // The seed returned by the server in TOCLIENT_AUTH_ACCEPT is stored here
526 u64 m_map_seed = 0;
527
528 // Auth data
529 std::string m_playername;
530 std::string m_password;
531 // If set, this will be sent (and cleared) upon a TOCLIENT_ACCEPT_SUDO_MODE
532 std::string m_new_password;
533 // Usable by auth mechanisms.
535 void *m_auth_data = nullptr;
536
537 bool m_access_denied = false;
539 std::string m_access_denied_reason = "";
540 std::queue<ClientEvent *> m_client_event_queue;
541 bool m_itemdef_received = false;
542 bool m_nodedef_received = false;
544 bool m_mods_loaded = false;
545
546 std::vector<std::string> m_remote_media_servers;
547 // Media downloader, only exists during init
548 std::unique_ptr<ClientMediaDownloader> m_media_downloader;
549 // Pending downloads of dynamic media (key: token)
550 std::vector<std::pair<u32, std::shared_ptr<SingleMediaDownloader>>> m_pending_media_downloads;
551
552 // An interval for generally sending object positions and stuff
554
555 // Sounds
557 // Mapping from server sound ids to our sound ids
558 std::unordered_map<s32, sound_handle_t> m_sounds_server_to_client;
559 // And the other way!
560 // This takes ownership for the sound handles.
561 std::unordered_map<sound_handle_t, s32> m_sounds_client_to_server;
562 // Relation of client id to object id
563 std::unordered_map<sound_handle_t, u16> m_sounds_to_objects;
564
565 // Privileges
566 std::unordered_set<std::string> m_privileges;
567
568 // Detached inventories
569 // key = name
570 std::unordered_map<std::string, Inventory*> m_detached_inventories;
571
572 // Storage for mesh data for creating multiple instances of the same mesh
574
575 // own state
577
578 // Used for saving server map to disk client-side
579 std::unique_ptr<MapDatabase> m_localdb;
582
583 // Client modding
587 std::vector<ModSpec> m_mods;
589
590 bool m_shutdown = false;
591
592 // CSM restrictions byteflag
595
596 std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
597
598 // The number of blocks the client will combine for mesh generation.
600};
Definition address.h:27
Definition camera.h:61
Definition clientenvironment.h:54
const std::set< std::string > & getPlayerNames()
Definition clientenvironment.h:129
Definition clientmedia.h:85
Definition scripting_client.h:27
Definition client.h:106
void setFatalError(const std::string &reason)
Definition client.h:319
void handleCommand_NodeDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:740
void handleCommand_DeleteParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1138
const std::string * getModFile(std::string filename)
Definition client.cpp:2004
ICraftDefManager * getCraftDefManager() override
Definition client.cpp:1942
void handleCommand_Privileges(NetworkPacket *pkt)
Definition clientpackethandler.cpp:891
bool activeObjectsReceived() const
Definition client.h:336
v3s16 getCrackPos()
Definition client.cpp:1669
void loadMods()
Definition client.cpp:182
void handleCommand_AuthAccept(NetworkPacket *pkt)
Definition clientpackethandler.cpp:133
void clearOutChatQueue()
Definition client.cpp:1352
void handleCommand_ModChannelMsg(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1694
MtEventManager * getEventManager()
Definition client.cpp:1968
std::unique_ptr< ParticleManager > m_particle_manager
Definition client.h:494
void handleCommand_DetachedInventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:920
StringMap m_mesh_data
Definition client.h:573
bool loadMedia(const std::string &data, const std::string &filename, bool from_media_push=false)
Definition client.cpp:796
std::unordered_map< sound_handle_t, u16 > m_sounds_to_objects
Definition client.h:563
void handleCommand_AddNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:243
IItemDefManager * getItemDefManager() override
Definition client.cpp:1934
void sendHaveMedia(const std::vector< u32 > &tokens)
Definition client.cpp:1461
float m_connection_reinit_timer
Definition client.h:476
float m_inventory_from_server_age
Definition client.h:510
void handleCommand_DenySudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:183
void handleCommand_PlayerSpeed(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1626
const std::string & getFormspecPrepend() const
Definition client.cpp:2075
void interact(InteractAction action, const PointedThing &pointed)
Definition client.cpp:1085
ClientEnvironment & getEnv()
Definition client.h:246
void request_media(const std::vector< std::string > &file_requests)
Definition client.cpp:907
bool checkCSMRestrictionFlag(CSMRestrictionFlags flag) const
Definition client.h:430
void Stop()
Definition client.cpp:318
MapNode CSMGetNode(v3s16 p, bool *is_valid_position)
Helper function for Client Side Modding CSM restrictions are applied there, this should not be used f...
Definition client.cpp:1508
void handleCommand_AnnounceMedia(NetworkPacket *pkt)
Definition clientpackethandler.cpp:619
ModStorageDatabase * getModStorageDatabase() override
Definition client.h:387
const ModSpec * getModSpec(const std::string &modname) const override
Definition client.cpp:313
u64 m_csm_restriction_flags
Definition client.h:593
scene::ISceneManager * getSceneManager()
Definition client.cpp:1599
std::queue< ClientEvent * > m_client_event_queue
Definition client.h:540
const Address getServerAddress()
Definition client.cpp:1797
void handleCommand_HP(NetworkPacket *pkt)
Definition clientpackethandler.cpp:529
void handleCommand_UpdatePlayerList(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1553
void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1749
void handleCommand_ActiveObjectMessages(NetworkPacket *pkt)
Definition clientpackethandler.cpp:455
bool nodedefReceived() const
Definition client.h:332
void handleCommand_ItemDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:762
StringMap m_mod_vfs
Definition client.h:588
Camera * getCamera()
Definition client.h:369
IntervalLimiter m_map_timer_and_unload_interval
Definition client.h:480
float m_recommended_send_interval
Definition client.h:553
std::unordered_map< s32, sound_handle_t > m_sounds_server_to_client
Definition client.h:558
float m_avg_rtt_timer
Definition client.h:477
s32 m_mapblock_limit_logged
Definition client.h:511
float m_mod_storage_save_timer
Definition client.h:586
static const std::string & getBuiltinLuaPath()
Definition client.cpp:295
void handleCommand_ChatMessage(NetworkPacket *pkt)
Definition clientpackethandler.cpp:369
IntervalLimiter m_localdb_save_interval
Definition client.h:580
MeshGrid getMeshGrid()
Definition client.h:443
void sendRemovedSounds(const std::vector< s32 > &soundList)
Definition client.cpp:1241
void handleCommand_HudSetParam(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1296
void handleCommand_HudSetSky(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1318
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1761
NodeDefManager * m_nodedef
Definition client.h:485
void sendRespawnLegacy()
Definition client.cpp:1378
void sendUpdateClientInfo(const ClientDynamicInfo &info)
Definition client.cpp:1474
bool m_mods_loaded
Definition client.h:544
bool m_simple_singleplayer_mode
Definition client.h:344
void addNode(v3s16 p, MapNode n, bool remove_metadata=true)
Definition client.cpp:1545
void handleCommand_HudSetStars(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1440
u32 m_sudo_auth_methods
Definition client.h:523
void handleCommand_Movement(NetworkPacket *pkt)
Definition clientpackethandler.cpp:485
std::vector< std::string > m_remote_media_servers
Definition client.h:546
void setCamera(Camera *camera)
Definition client.h:367
void handleCommand_HudSetMoon(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1427
std::unordered_map< sound_handle_t, s32 > m_sounds_client_to_server
Definition client.h:561
float m_animation_time
Definition client.h:514
void pushToChatQueue(ChatMessage *cec)
Definition client.h:406
void setPlayerControl(PlayerControl &control)
Definition client.cpp:1563
u64 getMapSeed() const
Definition client.h:304
LocalClientState m_state
Definition client.h:576
std::unique_ptr< con::IConnection > m_con
Definition client.h:495
std::vector< ModSpec > m_mods
Definition client.h:587
Camera * m_camera
Definition client.h:498
void handleCommand_LocalPlayerAnimations(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1508
void sendInventoryFields(const std::string &formname, const StringMap &fields)
Definition client.cpp:1278
int m_crack_level
Definition client.h:515
std::unique_ptr< ClientMediaDownloader > m_media_downloader
Definition client.h:548
ItemVisualsManager * m_item_visuals_manager
Definition client.h:489
IWritableShaderSource * m_shsrc
Definition client.h:483
std::unordered_map< std::string, Inventory * > m_detached_inventories
Definition client.h:570
std::unique_ptr< MapDatabase > m_localdb
Definition client.h:579
void sendNodemetaFields(v3s16 p, const std::string &formname, const StringMap &fields)
Definition client.cpp:1256
void sendInit(const std::string &playerName)
Definition client.cpp:1156
void scanModIntoMemory(const std::string &mod_name, const std::string &mod_path)
Definition client.h:133
void handleCommand_Hello(NetworkPacket *pkt)
Definition clientpackethandler.cpp:63
void deleteAuthData()
Definition client.cpp:1122
static AuthMechanism choseAuthMech(const u32 mechs)
Definition client.cpp:1142
bool hasClientEvents() const
Definition client.h:311
std::unique_ptr< Inventory > m_inventory_from_server
Definition client.h:509
void pushToEventQueue(ClientEvent *event)
Definition client.cpp:1927
std::string m_access_denied_reason
Definition client.h:539
bool itemdefReceived() const
Definition client.h:330
std::string m_password
Definition client.h:530
void inventoryAction(InventoryAction *a) override
Definition client.cpp:1648
std::string m_new_password
Definition client.h:532
void handleCommand_HudChange(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1213
Inventory * getInventory(const InventoryLocation &loc) override
Definition client.cpp:1604
const std::unordered_set< std::string > & getPrivilegeList() const
Definition client.h:298
void typeChatMessage(const std::wstring &message)
Definition client.cpp:1732
IWritableTextureSource * m_tsrc
Definition client.h:482
const std::set< std::string > & getConnectedPlayerNames()
Definition client.h:278
RenderingEngine * m_rendering_engine
Definition client.h:488
void Send(NetworkPacket *pkt)
Definition client.cpp:1044
float mediaReceiveProgress()
Definition client.cpp:1802
float m_removed_sounds_check_timer
Definition client.h:556
bool modsLoaded() const
Definition client.h:412
bool checkPrivilege(const std::string &priv) const
Definition client.h:295
void sendDamage(u16 damage)
Definition client.cpp:1371
void handleCommand_EyeOffset(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1528
std::queue< std::wstring > m_out_chat_queue
Definition client.h:517
u32 m_csm_restriction_noderange
Definition client.h:594
void handleCommand_FormspecPrepend(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1608
int CSMClampRadius(v3s16 pos, int radius)
Definition client.cpp:1520
ClientEvent * getClientEvent()
Definition client.cpp:1782
void handleCommand_SpawnParticleBatch(NetworkPacket *pkt)
Definition clientpackethandler.cpp:984
void makeScreenshot()
Definition client.cpp:1916
bool mediaReceived() const
Definition client.h:334
void handleCommand_MovePlayer(NetworkPacket *pkt)
Definition clientpackethandler.cpp:570
ISoundManager * m_sound
Definition client.h:486
void handleCommand_NodemetaChanged(NetworkPacket *pkt)
Definition clientpackethandler.cpp:260
std::string m_playername
Definition client.h:529
void sendDeletedBlocks(std::vector< v3s16 > &blocks)
Definition client.cpp:1218
IWritableItemDefManager * m_itemdef
Definition client.h:484
bool checkLocalPrivilege(const std::string &priv)
Definition client.h:383
virtual ISoundManager * getSoundManager()
Definition client.cpp:1964
void ProcessData(NetworkPacket *pkt)
Definition client.cpp:999
bool sendModChannelMessage(const std::string &channel, const std::string &message) override
Definition client.cpp:2051
u16 getProtoVersion() const
Definition client.h:339
void handleCommand_PlaySound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:784
void startAuth(AuthMechanism chosen_auth_mechanism)
Definition client.cpp:1167
void handleCommand_Null(NetworkPacket *pkt)
Definition client.h:162
bool joinModChannel(const std::string &channel) override
Definition client.cpp:2025
void handleCommand_SrpBytesSandB(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1575
void scanModSubfolder(const std::string &mod_name, const std::string &mod_path, std::string mod_subpath)
Definition client.cpp:266
~Client()
Definition client.cpp:341
void handleCommand_MovePlayerRel(NetworkPacket *pkt)
Definition clientpackethandler.cpp:601
void removeNode(v3s16 p)
Definition client.cpp:1486
u64 getCSMRestrictionFlags() const
Definition client.h:425
std::vector< std::pair< u32, std::shared_ptr< SingleMediaDownloader > > > m_pending_media_downloads
Definition client.h:550
u16 m_proto_ver
Definition client.h:506
bool canSendChatMessage() const
Definition client.cpp:1313
ISoundManager * sound()
Definition client.h:248
void handleCommand_InventoryFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:910
bool m_activeobjects_received
Definition client.h:543
void sendChangePassword(const std::string &oldpassword, const std::string &newpassword)
Definition client.cpp:1357
u16 allocateUnknownNodeId(const std::string &name) override
Definition client.cpp:1956
void handleCommand_Deprecated(NetworkPacket *pkt)
Definition clientpackethandler.cpp:56
void sendReady()
Definition client.cpp:1384
u8 m_server_ser_ver
Definition client.h:502
void handleCommand_HudSetFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1267
void step(float dtime)
Definition client.cpp:410
bool accessDenied() const
Definition client.h:315
const std::vector< ModSpec > & getMods() const override
Definition client.cpp:307
ELoginRegister m_allow_login_or_register
Definition client.h:497
bool m_update_wielded_item
Definition client.h:508
float m_chat_message_allowance
Definition client.h:519
void sendPlayerPos()
Definition client.cpp:1397
void handleCommand_HudSetSun(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1414
void * m_auth_data
Definition client.h:535
PacketCounter m_packetcounter
Definition client.h:512
ItemVisualsManager * getItemVisualsManager()
Definition client.h:389
int getCrackLevel()
Definition client.cpp:1664
u16 getHP()
Definition client.cpp:1694
int m_playerpos_repeat_count
Definition client.h:479
void handleCommand_RemoveNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:236
void sendChatMessage(const std::wstring &message)
Definition client.cpp:1327
void handleCommand_Breath(NetworkPacket *pkt)
Definition clientpackethandler.cpp:558
MeshGrid m_mesh_grid
Definition client.h:599
std::unique_ptr< MeshUpdateManager > m_mesh_update_manager
Definition client.h:492
void handleCommand_BlockData(NetworkPacket *pkt)
Definition clientpackethandler.cpp:286
std::unique_ptr< ModChannelMgr > m_modchannel_mgr
Definition client.h:596
void afterContentReceived()
Definition client.cpp:1845
void handleCommand_HudRemove(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1201
virtual IWritableShaderSource * getShaderSource()
Definition client.cpp:1951
bool m_internal_server
Definition client.h:351
float getCurRate()
Definition client.cpp:1909
void handleCommand_ActiveObjectRemoveAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:408
bool m_shutdown
Definition client.h:590
bool isShutdown()
Definition client.cpp:336
void handleCommand_Inventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:333
void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1766
ModStorageDatabase * m_mod_storage_database
Definition client.h:585
void handleCommand_OverrideDayNightRatio(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1492
bool m_nodedef_received
Definition client.h:542
u64 m_map_seed
Definition client.h:526
void handleCommand_MinimapModes(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1782
bool m_itemdef_received
Definition client.h:541
void setPlayerItem(u16 item)
Definition client.cpp:1570
LocalClientState getState()
Definition client.h:402
void migrateModStorage()
Definition client.cpp:155
float getRTT()
Definition client.cpp:1903
float m_playerpos_send_timer
Definition client.h:478
ModChannel * getModChannel(const std::string &channel) override
Definition client.cpp:2070
virtual scene::IAnimatedMesh * getMesh(const std::string &filename, bool cache=false)
Definition client.cpp:1978
bool m_access_denied
Definition client.h:537
bool inhibit_inventory_revert
Definition client.h:448
static const std::string & getClientModsLuaPath()
Definition client.cpp:301
Minimap * getMinimap()
Definition client.h:366
void handleCommand_AccessDenied(NetworkPacket *pkt)
Definition clientpackethandler.cpp:192
ITextureSource * getTextureSource()
Definition client.cpp:1947
void handleCommand_AddParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1007
const std::string & getAddressName() const
Definition client.h:420
void handleCommand_DeathScreenLegacy(NetworkPacket *pkt)
Definition clientpackethandler.cpp:612
u16 m_cache_save_interval
Definition client.h:581
void handleCommand_ModChannelSignal(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1712
void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1617
void connect(const Address &address, const std::string &address_name)
Definition client.cpp:386
void deletingPeer(con::IPeer *peer, bool timeout) override
Definition client.cpp:894
bool leaveModChannel(const std::string &channel) override
Definition client.cpp:2038
bool hasServerReplied() const
Definition client.h:362
AuthMechanism m_chosen_auth_mech
Definition client.h:534
std::queue< ChatMessage * > m_chat_queue
Definition client.h:520
std::unordered_set< std::string > m_privileges
Definition client.h:566
void handleCommand_Fov(NetworkPacket *pkt)
Definition clientpackethandler.cpp:509
void peerAdded(con::IPeer *peer) override
Definition client.cpp:888
void sendGotBlocks(const std::vector< v3s16 > &blocks)
Definition client.cpp:1231
MtEventManager * m_event
Definition client.h:487
void handleCommand_SetLighting(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1809
void handleCommand_MediaPush(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1637
void handleCommand(NetworkPacket *pkt)
Definition client.cpp:990
void handleCommand_TimeOfDay(NetworkPacket *pkt)
Definition clientpackethandler.cpp:352
bool isClient() override
Definition client.h:373
void setCrack(int level, v3s16 pos)
Definition client.cpp:1674
bool m_access_denied_reconnect
Definition client.h:538
bool updateWieldedItem()
Definition client.cpp:1582
bool reconnectRequested() const
Definition client.h:317
void initLocalMapSaving(const Address &address, const std::string &hostname)
Definition client.cpp:930
const NodeDefManager * getNodeDefManager() override
Definition client.cpp:1938
ClientScripting * getScript()
Definition client.h:411
void handleCommand_AcceptSudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:168
std::unique_ptr< Minimap > m_minimap
Definition client.h:499
v3s16 m_crack_pos
Definition client.h:516
DISABLE_CLASS_COPY(Client)
bool getChatMessage(std::wstring &message)
Definition client.cpp:1701
ITextureSource * tsrc()
Definition client.h:247
float m_packetcounter_timer
Definition client.h:475
std::string m_address_name
Definition client.h:496
void drawLoadScreen(const std::wstring &text, float dtime, int percent)
Definition client.cpp:1810
ClientEnvironment m_env
Definition client.h:493
void ReceiveAll()
Definition client.cpp:961
void sendInventoryAction(InventoryAction *a)
Definition client.cpp:1298
void handleCommand_SpawnParticle(NetworkPacket *pkt)
Definition clientpackethandler.cpp:969
const std::string & accessDeniedReason() const
Definition client.h:328
void handleCommand_HudAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1150
void handleCommand_ShowFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:953
void handleCommand_CloudParams(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1458
u32 m_last_chat_message_sent
Definition client.h:518
void handleCommand_Media(NetworkPacket *pkt)
Definition clientpackethandler.cpp:684
float getAnimationTime() const
Definition client.h:283
virtual ParticleManager * getParticleManager()
Definition client.cpp:1973
v3s16 CSMClampPos(v3s16 pos)
Definition client.cpp:1532
void showUpdateProgressTexture(void *args, float progress)
Definition client.cpp:1821
void handleCommand_FadeSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:878
void handleCommand_Camera(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1541
void handleCommand_StopSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:865
ClientScripting * m_script
Definition client.h:584
Definition craftdef.h:388
Definition gamedef.h:26
Definition itemdef.h:146
Definition sound.h:46
Definition texturesource.h:45
Definition itemdef.h:165
Definition shader.h:293
Definition texturesource.h:120
Definition numeric.h:386
Definition inventorymanager.h:96
Definition inventory.h:277
Definition c_types.h:32
Definition database.h:28
Definition mesh_generator_thread.h:142
Definition minimap.h:118
Definition modchannels.h:52
Definition modchannels.h:23
Definition database.h:79
Definition mtevent.h:42
Definition networkpacket.h:16
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:509
Definition client.h:77
std::map< u16, u32 > m_packets
Definition client.h:100
void print(std::ostream &o) const
Definition client.cpp:86
void add(u16 command)
Definition client.h:81
PacketCounter()=default
u32 sum() const
Definition client.cpp:78
void clear()
Definition client.h:90
Class doing particle as well as their spawners handling.
Definition particles.h:211
Definition renderingengine.h:64
Definition clientmedia.h:186
Definition connection.h:47
Definition connection.h:34
Definition peerhandler.h:13
LocalClientState
Definition client.h:66
@ LC_Init
Definition client.h:68
@ LC_Created
Definition client.h:67
@ LC_Ready
Definition client.h:69
int sound_handle_t
Definition client.h:64
ELoginRegister
Definition gameparams.h:21
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
Definition client.h:61
Definition camera.h:24
Definition al_extensions.cpp:11
CSMRestrictionFlags
Definition networkprotocol.h:953
@ CSM_RF_NONE
Definition networkprotocol.h:954
InteractAction
Definition networkprotocol.h:969
AuthMechanism
Definition networkprotocol.h:915
std::unordered_map< std::string, std::string > StringMap
Definition string.h:66
Definition chatmessage.h:20
Definition clientdynamicinfo.h:12
Definition clientevent.h:69
Definition inventorymanager.h:116
Definition inventorymanager.h:18
Definition item_visuals_manager.h:22
Definition clientmap.h:14
Definition mapnode.h:123
Describes a grid with given step, oirginating at (0,0,0)
Definition numeric.h:157
Definition mods.h:18
Definition player.h:43
An active object or node which is selected by a ray on the map.
Definition pointedthing.h:22
static std::string p(std::string path)
Definition test_filesys.cpp:64