Luanti 5.18.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;
48class ClientScripting;
49class SSCSMController;
50struct ChatMessage;
52struct ClientEvent;
53struct MapDrawControl;
54struct MapNode;
55struct PlayerControl;
56struct PointedThing;
58struct ModVFS;
59
60namespace scene {
61class IAnimatedMesh;
62}
63
64namespace con {
65class IConnection;
66}
67using sound_handle_t = int;
68
74
75/*
76 Packet counter
77*/
78
80{
81public:
82 PacketCounter() = default;
83
84 void add(u16 command)
85 {
86 auto n = m_packets.find(command);
87 if (n == m_packets.end())
88 m_packets[command] = 1;
89 else
90 n->second++;
91 }
92
93 void clear()
94 {
95 m_packets.clear();
96 }
97
98 u32 sum() const;
99 void print(std::ostream &o) const;
100
101private:
102 // command, count
103 std::map<u16, u32> m_packets;
104};
105
106class Client : public con::PeerHandler, public InventoryManager, public IGameDef
107{
108public:
109 /*
110 NOTE: Nothing is thread-safe here.
111 */
112
113 Client(
114 const char *playername,
115 const std::string &password,
116 MapDrawControl &control,
120 NodeDefManager *nodedef,
122 MtEventManager *event,
123 RenderingEngine *rendering_engine,
124 ItemVisualsManager *item_visuals,
125 ELoginRegister allow_login_or_register
126 );
127
128 ~Client();
130
131 /*
132 request all threads managed by client to be stopped
133 */
134 void Stop();
135
136
137 bool isShutdown();
138
139 void connect(const Address &address, const std::string &address_name);
140
141 /*
142 Stuff that references the environment is valid only as
143 long as this is not called. (eg. Players)
144 If this throws a PeerNotFoundException, the connection has
145 timed out.
146 */
147 void step(float dtime);
148
149 /*
150 * Command Handlers
151 */
152
153 void handleCommand(NetworkPacket* pkt);
154
217
218 void ProcessData(NetworkPacket *pkt);
219
220 void Send(NetworkPacket* pkt);
221
222 void interact(InteractAction action, const PointedThing &pointed);
223
224 void sendNodemetaFields(v3s16 p, const std::string &formname,
225 const StringMap &fields);
226 void sendInventoryFields(const std::string &formname,
227 const StringMap &fields);
229 void sendChatMessage(const std::wstring &message);
230 void clearOutChatQueue();
231 void sendChangePassword(const std::string &oldpassword,
232 const std::string &newpassword);
233 void sendDamage(u16 damage);
234 void sendRespawnLegacy();
235 void sendReady();
236 void sendHaveMedia(const std::vector<u32> &tokens);
237 void sendUpdateClientInfo(const ClientDynamicInfo &info);
238
242 static const std::string &getBuiltinLuaPath();
243 static const std::string &getClientModsLuaPath();
244
245 const std::vector<ModSpec> &getMods() const override;
246 const ModSpec* getModSpec(const std::string &modname) const override;
247
248 // Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
249 void removeNode(v3s16 p);
250
251 // helpers to enforce CSM restrictions
252 MapNode CSMGetNode(v3s16 p, bool *is_valid_position);
253 int CSMClampRadius(v3s16 pos, int radius);
255
256 void addNode(v3s16 p, MapNode n, bool remove_metadata = true);
257
258 void setPlayerControl(PlayerControl &control);
259
260 // Returns true if the inventory of the local player has been
261 // updated from the server. If it is true, it is set to false.
262 bool updateWieldedItem();
263
265
266 /* InventoryManager interface */
267 Inventory* getInventory(const InventoryLocation &loc) override;
268 void inventoryAction(InventoryAction *a) override;
269
270 // Send the item number 'item' as player item to the server
271 void setPlayerItem(u16 item);
272
273 const std::set<std::string> &getConnectedPlayerNames()
274 {
275 return m_env.getPlayerNames();
276 }
277
278 float getAnimationTime() const
279 {
280 return m_animation_time;
281 }
282
284 int getCrackLevel();
286 void setCrack(int level, v3s16 pos);
287
288 u16 getHP();
289
290 bool checkPrivilege(const std::string &priv) const
291 { return (m_privileges.count(priv) != 0); }
292
293 const std::unordered_set<std::string> &getPrivilegeList() const
294 { return m_privileges; }
295
296 bool getChatMessage(std::wstring &message);
297 void typeChatMessage(const std::wstring& message);
298
299 u64 getMapSeed() const { return m_map_seed; }
300
301 void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
302 // Including blocks at appropriate edges
303 void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
304 void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);
305
306 bool hasClientEvents() const { return !m_client_event_queue.empty(); }
307 // Get event from queue. If queue is empty, it triggers an assertion failure.
309
310 bool accessDenied() const { return m_access_denied; }
311
313
314 void setFatalError(const std::string &reason)
315 {
316 m_access_denied = true;
317 m_access_denied_reason = reason;
318 }
319 void setFatalError(const LuaError &e);
320
321 // Renaming accessDeniedReason to better name could be good as it's used to
322 // disconnect client when CSM failed.
323 const std::string &accessDeniedReason() const { return m_access_denied_reason; }
324
325 bool itemdefReceived() const
326 { return m_itemdef_received; }
327 bool nodedefReceived() const
328 { return m_nodedef_received; }
329 bool mediaReceived() const
330 { return !m_media_downloader; }
333
334 u16 getProtoVersion() const
335 { return m_proto_ver; }
336
337 // Whether the server is in "simple singleplayer mode".
338 // This implies "m_internal_server = true".
340
341 // Whether the server is hosted by the same Luanti instance and singletons
342 // like g_settings are shared between client and server.
343 //
344 // This is intentionally *not* true if we're just connecting to a localhost
345 // server hosted by a different Luanti instance.
347
348 bool mediaReceiveProgress(s32 &received, s32 &total, size_t &received_size) const;
349
350 void drawLoadScreen(const std::wstring &text, float dtime, int percent);
352 void loadSSCSM();
353 void showUpdateProgressTexture(void *args, float progress);
354
355 float getRTT();
356 float getCurRate();
357 // has the server ever replied to us, used for connection retry/fallback
358 bool hasServerReplied() const {
359 return getProtoVersion() != 0; // (set in TOCLIENT_HELLO)
360 }
361
362 Minimap* getMinimap() { return m_minimap.get(); }
363 void setCamera(Camera* camera) { m_camera = camera; }
364
365 Camera* getCamera () { return m_camera; }
366 scene::ISceneManager *getSceneManager();
367
368 // IGameDef interface
369 bool isClient() override { return true; }
371 const NodeDefManager* getNodeDefManager() override;
375 u16 allocateUnknownNodeId(const std::string &name) override;
379
380 bool checkLocalPrivilege(const std::string &priv)
381 { return checkPrivilege(priv); }
382
383 // Gets a pointer to a named mesh
384 // If you want to modify it, you may need to clone it first (-> `is_shared`)
385 // (the returned pointer must be dropped)
386 scene::IAnimatedMesh *getMesh(const std::string &filename, bool *is_shared = nullptr);
387
388 ModVFS *getModVFS() { return m_mod_vfs.get(); }
390
392
393 // Migrates away old files-based mod storage if necessary
394 void migrateModStorage();
395
396 // The following set of functions is used by ClientMediaDownloader
397 // Insert a media file appropriately into the appropriate manager
398 bool loadMedia(const std::string &data, const std::string &filename,
399 bool from_media_push = false);
400
401 // Send a request for conventional media transfer
402 void requestMedia(const std::vector<std::string> &file_requests);
403
405
406 // Request a screenshot to be taken at the end of the frame.
408
409 // Must be called right before endScene() to take requested screenshots.
411
412 inline void pushToChatQueue(ChatMessage *cec)
413 {
414 m_chat_queue.push(cec);
415 }
416
418 bool modsLoaded() const { return m_mods_loaded; }
419
420 void pushToEventQueue(ClientEvent *event);
421
422 // IP and port we're connected to
424
425 // Hostname of the connected server (but can also be a numerical IP)
426 const std::string &getAddressName() const
427 {
428 return m_address_name;
429 }
430
431 inline u64 getCSMRestrictionFlags() const
432 {
434 }
435
437 {
438 return m_csm_restriction_flags & flag;
439 }
440
441 bool joinModChannel(const std::string &channel) override;
442 bool leaveModChannel(const std::string &channel) override;
443 bool sendModChannelMessage(const std::string &channel,
444 const std::string &message) override;
445 ModChannel *getModChannel(const std::string &channel) override;
446
447 const std::string &getFormspecPrepend() const;
448
449 inline MeshGrid getMeshGrid() const
450 {
451 return m_mesh_grid;
452 }
453
455
456private:
458 // Tokens to ack to the server. multiple because server can send duplicate
459 // requests
460 std::vector<u32> tokens;
461 std::string name; // Filename
462 std::shared_ptr<SingleMediaDownloader> d;
463
464 PendingMediaDownload(u32 token, const std::string &name,
465 const std::shared_ptr<SingleMediaDownloader> &d) : name(name), d(d)
466 {
467 tokens.push_back(token);
468 }
469 };
470
471 void loadMods();
472
473 // Virtual methods from con::PeerHandler
474 void peerAdded(con::IPeer *peer) override;
475 void deletingPeer(con::IPeer *peer, bool timeout) override;
476
477 void initLocalMapSaving(const Address &address, const std::string &hostname);
478
479 void ReceiveAll();
480
481 void sendPlayerPos();
482
483 void deleteAuthData();
484 // helper method shared with clientpackethandler
485 static AuthMechanism choseAuthMech(const u32 mechs);
486
487 void sendInit(const std::string &playerName);
488 void startAuth(AuthMechanism chosen_auth_mechanism);
489 void sendDeletedBlocks(std::vector<v3s16> &blocks);
490 void sendGotBlocks(const std::vector<v3s16> &blocks);
491 void sendRemovedSounds(const std::vector<s32> &soundList);
492
493 bool canSendChatMessage() const;
494
497 float m_avg_rtt_timer = 0.0f;
501
510
511
512 std::unique_ptr<MeshUpdateManager> m_mesh_update_manager;
514 std::unique_ptr<ParticleManager> m_particle_manager;
515 std::unique_ptr<con::IConnection> m_con;
516 std::string m_address_name;
518 Camera *m_camera = nullptr;
519 std::unique_ptr<Minimap> m_minimap;
520
521 // Server serialization version
523
524 // Used version of the protocol with server
525 // If 0, server init hasn't been received yet.
526 u16 m_proto_ver = 0;
527
530 std::unique_ptr<Inventory> m_inventory_from_server;
534 // Block mesh animation parameters
535 float m_animation_time = 0.0f;
538 std::queue<std::wstring> m_out_chat_queue;
541 std::queue<ChatMessage *> m_chat_queue;
542
543 // The authentication methods we can use to enter sudo mode (=change password)
545
546 // The seed returned by the server in TOCLIENT_AUTH_ACCEPT is stored here
547 u64 m_map_seed = 0;
548
549 // Auth data
550 std::string m_playername;
551 std::string m_password;
552 // If set, this will be sent (and cleared) upon a TOCLIENT_ACCEPT_SUDO_MODE
553 std::string m_new_password;
554 // Usable by auth mechanisms.
556 void *m_auth_data = nullptr;
557
558 bool m_access_denied = false;
560 std::string m_access_denied_reason = "";
561 std::queue<ClientEvent *> m_client_event_queue;
562 bool m_itemdef_received = false;
563 bool m_nodedef_received = false;
565 bool m_mods_loaded = false;
566
567 std::vector<std::string> m_remote_media_servers;
568 // Media downloader, only exists during init
569 std::unique_ptr<ClientMediaDownloader> m_media_downloader;
570 // Pending downloads of dynamic media
571 std::vector<PendingMediaDownload> m_pending_media_downloads;
572
573 // An interval for generally sending object positions and stuff
575
576 // Sounds
578 // Mapping from server sound ids to our sound ids
579 std::unordered_map<s32, sound_handle_t> m_sounds_server_to_client;
580 // And the other way!
581 // This takes ownership for the sound handles.
582 std::unordered_map<sound_handle_t, s32> m_sounds_client_to_server;
583 // Relation of client id to object id
584 std::unordered_map<sound_handle_t, u16> m_sounds_to_objects;
585
586 // Privileges
587 std::unordered_set<std::string> m_privileges;
588
589 // Detached inventories
590 // key = name
591 std::unordered_map<std::string, Inventory*> m_detached_inventories;
592
593 // Storage for mesh data for creating multiple instances of the same mesh
595
596 // own state
598
599 // Used for saving server map to disk client-side
600 std::unique_ptr<MapDatabase> m_localdb;
603
604 // Client modding
608 std::vector<ModSpec> m_mods;
609 std::unique_ptr<ModVFS> m_mod_vfs;
610
611 // SSCSM
612 std::unique_ptr<SSCSMController> m_sscsm_controller;
613
614 bool m_shutdown = false;
615 bool m_take_screenshot = false;
616
617 // CSM restrictions byteflag
620
621 std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
622
623 // The number of blocks the client will combine for mesh generation.
625};
Definition address.h:27
Definition camera.h:61
Definition clientenvironment.h:54
Definition clientmedia.h:85
Definition scripting_client.h:27
bool m_skip_next_wield_animation
Definition client.h:529
void setFatalError(const std::string &reason)
Definition client.h:314
void handleCommand_NodeDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:745
void handleCommand_DeleteParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1149
ICraftDefManager * getCraftDefManager() override
Definition client.cpp:2014
void handleCommand_Privileges(NetworkPacket *pkt)
Definition clientpackethandler.cpp:902
bool activeObjectsReceived() const
Definition client.h:331
v3s16 getCrackPos()
Definition client.cpp:1711
std::unique_ptr< ModVFS > m_mod_vfs
Definition client.h:609
void loadMods()
Definition client.cpp:234
void handleCommand_AuthAccept(NetworkPacket *pkt)
Definition clientpackethandler.cpp:134
void clearOutChatQueue()
Definition client.cpp:1387
void handleCommand_ModChannelMsg(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1769
MtEventManager * getEventManager()
Definition client.cpp:2040
std::unique_ptr< ParticleManager > m_particle_manager
Definition client.h:514
void handleCommand_DetachedInventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:931
StringMap m_mesh_data
Definition client.h:594
bool loadMedia(const std::string &data, const std::string &filename, bool from_media_push=false)
Definition client.cpp:820
std::unordered_map< sound_handle_t, u16 > m_sounds_to_objects
Definition client.h:584
void handleCommand_AddNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:253
IItemDefManager * getItemDefManager() override
Definition client.cpp:2006
void sendHaveMedia(const std::vector< u32 > &tokens)
Definition client.cpp:1496
float m_connection_reinit_timer
Definition client.h:496
float m_inventory_from_server_age
Definition client.h:531
void handleCommand_DenySudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:184
void handleCommand_PlayerSpeed(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1690
const std::string & getFormspecPrepend() const
Definition client.cpp:2135
void interact(InteractAction action, const PointedThing &pointed)
Definition client.cpp:1120
ClientEnvironment & getEnv()
Definition client.h:239
bool checkCSMRestrictionFlag(CSMRestrictionFlags flag) const
Definition client.h:436
void Stop()
Definition client.cpp:343
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:1543
void handleCommand_AnnounceMedia(NetworkPacket *pkt)
Definition clientpackethandler.cpp:624
ModStorageDatabase * getModStorageDatabase() override
Definition client.h:389
const ModSpec * getModSpec(const std::string &modname) const override
Definition client.cpp:338
u64 m_csm_restriction_flags
Definition client.h:618
scene::ISceneManager * getSceneManager()
Definition client.cpp:1641
std::queue< ClientEvent * > m_client_event_queue
Definition client.h:561
const Address getServerAddress()
Definition client.cpp:1839
void handleCommand_HP(NetworkPacket *pkt)
Definition clientpackethandler.cpp:533
void handleCommand_UpdatePlayerList(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1617
void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1791
void handleCommand_ActiveObjectMessages(NetworkPacket *pkt)
Definition clientpackethandler.cpp:469
bool nodedefReceived() const
Definition client.h:327
void handleCommand_ItemDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:767
Camera * getCamera()
Definition client.h:365
IntervalLimiter m_map_timer_and_unload_interval
Definition client.h:500
float m_recommended_send_interval
Definition client.h:574
std::unordered_map< s32, sound_handle_t > m_sounds_server_to_client
Definition client.h:579
float m_avg_rtt_timer
Definition client.h:497
s32 m_mapblock_limit_logged
Definition client.h:532
float m_mod_storage_save_timer
Definition client.h:607
static const std::string & getBuiltinLuaPath()
Definition client.cpp:320
void handleCommand_ChatMessage(NetworkPacket *pkt)
Definition clientpackethandler.cpp:386
IntervalLimiter m_localdb_save_interval
Definition client.h:601
void sendRemovedSounds(const std::vector< s32 > &soundList)
Definition client.cpp:1276
void handleCommand_HudSetParam(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1338
void handleCommand_HudSetSky(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1360
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1803
NodeDefManager * m_nodedef
Definition client.h:505
void sendRespawnLegacy()
Definition client.cpp:1413
void sendUpdateClientInfo(const ClientDynamicInfo &info)
Definition client.cpp:1509
bool m_mods_loaded
Definition client.h:565
void takeScreenshotIfRequested()
Definition client.cpp:1984
bool m_simple_singleplayer_mode
Definition client.h:339
void addNode(v3s16 p, MapNode n, bool remove_metadata=true)
Definition client.cpp:1580
void handleCommand_HudSetStars(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1491
u32 m_sudo_auth_methods
Definition client.h:544
bool m_take_screenshot
Definition client.h:615
void handleCommand_Movement(NetworkPacket *pkt)
Definition clientpackethandler.cpp:490
std::vector< std::string > m_remote_media_servers
Definition client.h:567
void setCamera(Camera *camera)
Definition client.h:363
void handleCommand_HudSetMoon(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1478
std::unordered_map< sound_handle_t, s32 > m_sounds_client_to_server
Definition client.h:582
float m_animation_time
Definition client.h:535
void pushToChatQueue(ChatMessage *cec)
Definition client.h:412
void setPlayerControl(PlayerControl &control)
Definition client.cpp:1598
u64 getMapSeed() const
Definition client.h:299
LocalClientState m_state
Definition client.h:597
std::unique_ptr< con::IConnection > m_con
Definition client.h:515
std::vector< ModSpec > m_mods
Definition client.h:608
Camera * m_camera
Definition client.h:518
void handleCommand_LocalPlayerAnimations(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1567
void sendInventoryFields(const std::string &formname, const StringMap &fields)
Definition client.cpp:1313
int m_crack_level
Definition client.h:536
std::unique_ptr< ClientMediaDownloader > m_media_downloader
Definition client.h:569
ItemVisualsManager * m_item_visuals_manager
Definition client.h:509
IWritableShaderSource * m_shsrc
Definition client.h:503
std::unordered_map< std::string, Inventory * > m_detached_inventories
Definition client.h:591
std::unique_ptr< MapDatabase > m_localdb
Definition client.h:600
void sendNodemetaFields(v3s16 p, const std::string &formname, const StringMap &fields)
Definition client.cpp:1291
void sendInit(const std::string &playerName)
Definition client.cpp:1191
void handleCommand_Hello(NetworkPacket *pkt)
Definition clientpackethandler.cpp:63
void deleteAuthData()
Definition client.cpp:1157
static AuthMechanism choseAuthMech(const u32 mechs)
Definition client.cpp:1177
bool hasClientEvents() const
Definition client.h:306
std::unique_ptr< Inventory > m_inventory_from_server
Definition client.h:530
void pushToEventQueue(ClientEvent *event)
Definition client.cpp:1999
std::string m_access_denied_reason
Definition client.h:560
bool itemdefReceived() const
Definition client.h:325
std::string m_password
Definition client.h:551
void inventoryAction(InventoryAction *a) override
Definition client.cpp:1690
std::string m_new_password
Definition client.h:553
void handleCommand_HudChange(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1251
Inventory * getInventory(const InventoryLocation &loc) override
Definition client.cpp:1646
const std::unordered_set< std::string > & getPrivilegeList() const
Definition client.h:293
void typeChatMessage(const std::wstring &message)
Definition client.cpp:1774
IWritableTextureSource * m_tsrc
Definition client.h:502
const std::set< std::string > & getConnectedPlayerNames()
Definition client.h:273
RenderingEngine * m_rendering_engine
Definition client.h:508
void Send(NetworkPacket *pkt)
Definition client.cpp:1079
float m_removed_sounds_check_timer
Definition client.h:577
std::unique_ptr< SSCSMController > m_sscsm_controller
Definition client.h:612
bool modsLoaded() const
Definition client.h:418
bool checkPrivilege(const std::string &priv) const
Definition client.h:290
void sendDamage(u16 damage)
Definition client.cpp:1406
void handleCommand_EyeOffset(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1587
std::queue< std::wstring > m_out_chat_queue
Definition client.h:538
u32 m_csm_restriction_noderange
Definition client.h:619
void handleCommand_FormspecPrepend(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1672
int CSMClampRadius(v3s16 pos, int radius)
Definition client.cpp:1555
ClientEvent * getClientEvent()
Definition client.cpp:1824
void handleCommand_SpawnParticleBatch(NetworkPacket *pkt)
Definition clientpackethandler.cpp:993
bool mediaReceived() const
Definition client.h:329
void handleCommand_MovePlayer(NetworkPacket *pkt)
Definition clientpackethandler.cpp:575
ISoundManager * m_sound
Definition client.h:506
void handleCommand_NodemetaChanged(NetworkPacket *pkt)
Definition clientpackethandler.cpp:270
std::string m_playername
Definition client.h:550
void sendDeletedBlocks(std::vector< v3s16 > &blocks)
Definition client.cpp:1253
IWritableItemDefManager * m_itemdef
Definition client.h:504
bool checkLocalPrivilege(const std::string &priv)
Definition client.h:380
virtual ISoundManager * getSoundManager()
Definition client.cpp:2036
void ProcessData(NetworkPacket *pkt)
Definition client.cpp:1034
bool sendModChannelMessage(const std::string &channel, const std::string &message) override
Definition client.cpp:2111
u16 getProtoVersion() const
Definition client.h:334
void handleCommand_PlaySound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:789
void startAuth(AuthMechanism chosen_auth_mechanism)
Definition client.cpp:1202
void handleCommand_Null(NetworkPacket *pkt)
Definition client.h:155
bool joinModChannel(const std::string &channel) override
Definition client.cpp:2085
void requestScreenshot()
Definition client.h:407
void handleCommand_SrpBytesSandB(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1639
~Client()
Definition client.cpp:366
void handleCommand_MovePlayerRel(NetworkPacket *pkt)
Definition clientpackethandler.cpp:606
void removeNode(v3s16 p)
Definition client.cpp:1521
u64 getCSMRestrictionFlags() const
Definition client.h:431
void requestMedia(const std::vector< std::string > &file_requests)
Definition client.cpp:933
u16 m_proto_ver
Definition client.h:526
bool canSendChatMessage() const
Definition client.cpp:1348
ISoundManager * sound()
Definition client.h:241
void loadSSCSM()
Definition client.cpp:1951
std::vector< PendingMediaDownload > m_pending_media_downloads
Definition client.h:571
void handleCommand_InventoryFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:921
bool consumeSkipNextWieldAnimation()
Definition client.cpp:1634
bool m_activeobjects_received
Definition client.h:564
void sendChangePassword(const std::string &oldpassword, const std::string &newpassword)
Definition client.cpp:1392
u16 allocateUnknownNodeId(const std::string &name) override
Definition client.cpp:2028
void handleCommand_Deprecated(NetworkPacket *pkt)
Definition clientpackethandler.cpp:56
void sendReady()
Definition client.cpp:1419
u8 m_server_ser_ver
Definition client.h:522
void handleCommand_HudSetFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1309
void step(float dtime)
Definition client.cpp:430
bool accessDenied() const
Definition client.h:310
const std::vector< ModSpec > & getMods() const override
Definition client.cpp:332
ELoginRegister m_allow_login_or_register
Definition client.h:517
bool m_update_wielded_item
Definition client.h:528
float m_chat_message_allowance
Definition client.h:540
void sendPlayerPos()
Definition client.cpp:1432
void handleCommand_HudSetSun(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1465
void * m_auth_data
Definition client.h:556
PacketCounter m_packetcounter
Definition client.h:533
ItemVisualsManager * getItemVisualsManager()
Definition client.h:391
int getCrackLevel()
Definition client.cpp:1706
u16 getHP()
Definition client.cpp:1736
int m_playerpos_repeat_count
Definition client.h:499
void handleCommand_RemoveNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:246
void sendChatMessage(const std::wstring &message)
Definition client.cpp:1362
void handleCommand_Breath(NetworkPacket *pkt)
Definition clientpackethandler.cpp:563
MeshGrid m_mesh_grid
Definition client.h:624
std::unique_ptr< MeshUpdateManager > m_mesh_update_manager
Definition client.h:512
void handleCommand_BlockData(NetworkPacket *pkt)
Definition clientpackethandler.cpp:296
std::unique_ptr< ModChannelMgr > m_modchannel_mgr
Definition client.h:621
void afterContentReceived()
Definition client.cpp:1889
void handleCommand_HudRemove(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1239
virtual IWritableShaderSource * getShaderSource()
Definition client.cpp:2023
bool m_internal_server
Definition client.h:346
float getCurRate()
Definition client.cpp:1977
void handleCommand_ActiveObjectRemoveAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:425
bool m_shutdown
Definition client.h:614
bool isShutdown()
Definition client.cpp:361
void handleCommand_Inventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:342
void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1808
ModStorageDatabase * m_mod_storage_database
Definition client.h:606
void handleCommand_OverrideDayNightRatio(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1551
bool m_nodedef_received
Definition client.h:563
u64 m_map_seed
Definition client.h:547
Client(const char *playername, const std::string &password, MapDrawControl &control, IWritableTextureSource *tsrc, IWritableShaderSource *shsrc, IWritableItemDefManager *itemdef, NodeDefManager *nodedef, ISoundManager *sound, MtEventManager *event, RenderingEngine *rendering_engine, ItemVisualsManager *item_visuals, ELoginRegister allow_login_or_register)
Definition client.cpp:128
void handleCommand_MinimapModes(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1857
bool m_itemdef_received
Definition client.h:562
void setPlayerItem(u16 item)
Definition client.cpp:1605
scene::IAnimatedMesh * getMesh(const std::string &filename, bool *is_shared=nullptr)
Definition client.cpp:2050
void migrateModStorage()
Definition client.cpp:207
float getRTT()
Definition client.cpp:1971
float m_playerpos_send_timer
Definition client.h:498
ModChannel * getModChannel(const std::string &channel) override
Definition client.cpp:2130
bool m_access_denied
Definition client.h:558
bool inhibit_inventory_revert
Definition client.h:454
LocalClientState getState() const
Definition client.h:404
static const std::string & getClientModsLuaPath()
Definition client.cpp:326
Minimap * getMinimap()
Definition client.h:362
void handleCommand_AccessDenied(NetworkPacket *pkt)
Definition clientpackethandler.cpp:193
ITextureSource * getTextureSource()
Definition client.cpp:2019
void handleCommand_AddParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1016
const std::string & getAddressName() const
Definition client.h:426
void handleCommand_DeathScreenLegacy(NetworkPacket *pkt)
Definition clientpackethandler.cpp:617
u16 m_cache_save_interval
Definition client.h:602
void handleCommand_ModChannelSignal(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1787
void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1681
void connect(const Address &address, const std::string &address_name)
Definition client.cpp:405
void deletingPeer(con::IPeer *peer, bool timeout) override
Definition client.cpp:920
bool leaveModChannel(const std::string &channel) override
Definition client.cpp:2098
bool hasServerReplied() const
Definition client.h:358
MeshGrid getMeshGrid() const
Definition client.h:449
AuthMechanism m_chosen_auth_mech
Definition client.h:555
bool mediaReceiveProgress(s32 &received, s32 &total, size_t &received_size) const
Definition client.cpp:1844
std::queue< ChatMessage * > m_chat_queue
Definition client.h:541
std::unordered_set< std::string > m_privileges
Definition client.h:587
void handleCommand_Fov(NetworkPacket *pkt)
Definition clientpackethandler.cpp:514
void peerAdded(con::IPeer *peer) override
Definition client.cpp:914
void sendGotBlocks(const std::vector< v3s16 > &blocks)
Definition client.cpp:1266
MtEventManager * m_event
Definition client.h:507
void handleCommand_SetLighting(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1884
void handleCommand_MediaPush(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1701
void handleCommand(NetworkPacket *pkt)
Definition client.cpp:1025
void handleCommand_TimeOfDay(NetworkPacket *pkt)
Definition clientpackethandler.cpp:369
bool isClient() override
Definition client.h:369
void setCrack(int level, v3s16 pos)
Definition client.cpp:1716
bool m_access_denied_reconnect
Definition client.h:559
bool updateWieldedItem()
Definition client.cpp:1617
bool reconnectRequested() const
Definition client.h:312
void initLocalMapSaving(const Address &address, const std::string &hostname)
Definition client.cpp:956
const NodeDefManager * getNodeDefManager() override
Definition client.cpp:2010
ClientScripting * getScript()
Definition client.h:417
void handleCommand_AcceptSudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:169
std::unique_ptr< Minimap > m_minimap
Definition client.h:519
ModVFS * getModVFS()
Definition client.h:388
v3s16 m_crack_pos
Definition client.h:537
DISABLE_CLASS_COPY(Client)
bool getChatMessage(std::wstring &message)
Definition client.cpp:1743
ITextureSource * tsrc()
Definition client.h:240
float m_packetcounter_timer
Definition client.h:495
std::string m_address_name
Definition client.h:516
void drawLoadScreen(const std::wstring &text, float dtime, int percent)
Definition client.cpp:1854
ClientEnvironment m_env
Definition client.h:513
void ReceiveAll()
Definition client.cpp:987
void sendInventoryAction(InventoryAction *a)
Definition client.cpp:1333
void handleCommand_SpawnParticle(NetworkPacket *pkt)
Definition clientpackethandler.cpp:979
const std::string & accessDeniedReason() const
Definition client.h:323
void handleCommand_HudAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1161
void handleCommand_ShowFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:963
void handleCommand_CloudParams(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1516
u32 m_last_chat_message_sent
Definition client.h:539
void handleCommand_Media(NetworkPacket *pkt)
Definition clientpackethandler.cpp:689
float getAnimationTime() const
Definition client.h:278
virtual ParticleManager * getParticleManager()
Definition client.cpp:2045
v3s16 CSMClampPos(v3s16 pos)
Definition client.cpp:1567
void showUpdateProgressTexture(void *args, float progress)
Definition client.cpp:1865
void handleCommand_FadeSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:889
void handleCommand_Camera(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1603
void handleCommand_StopSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:876
ClientScripting * m_script
Definition client.h:605
Definition craftdef.h:394
Definition gamedef.h:26
Definition itemdef.h:146
Definition sound.h:46
Definition texturesource.h:45
Definition itemdef.h:167
Definition shader.h:309
Definition texturesource.h:120
Definition numeric.h:386
InventoryManager()=default
Definition inventory.h:277
Definition c_types.h:32
Definition database.h:28
Definition mesh_generator_thread.h:146
Definition minimap.h:118
Definition modchannels.h:52
Definition modchannels.h:23
Definition database.h:79
Definition mtevent.h:40
Definition networkpacket.h:16
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:514
Definition client.h:80
std::map< u16, u32 > m_packets
Definition client.h:103
void print(std::ostream &o) const
Definition client.cpp:93
void add(u16 command)
Definition client.h:84
PacketCounter()=default
u32 sum() const
Definition client.cpp:85
void clear()
Definition client.h:93
Class doing particle as well as their spawners handling.
Definition particles.h:211
Definition renderingengine.h:64
The purpose of this class is to:
Definition sscsm_controller.h:25
Definition clientmedia.h:187
Definition connection.h:47
Definition connection.h:34
Definition peerhandler.h:13
LocalClientState
Definition client.h:69
@ LC_Init
Definition client.h:71
@ LC_Created
Definition client.h:70
@ LC_Ready
Definition client.h:72
int sound_handle_t
IDs for playing sounds.
Definition client.h:67
ELoginRegister
Definition gameparams.h:23
@ Any
Definition gameparams.h:24
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
static std::string percent(size_t n, size_t total)
Definition main.cpp:1279
Definition client.h:64
Definition camera.h:24
Definition al_extensions.cpp:11
CSMRestrictionFlags
Definition networkprotocol.h:965
@ CSM_RF_NONE
Definition networkprotocol.h:966
InteractAction
Definition networkprotocol.h:981
AuthMechanism
Definition networkprotocol.h:927
std::unordered_map< std::string, std::string > StringMap
Definition string.h:69
Definition chatmessage.h:20
Definition clientdynamicinfo.h:12
Definition clientevent.h:70
PendingMediaDownload(u32 token, const std::string &name, const std::shared_ptr< SingleMediaDownloader > &d)
Definition client.h:464
std::shared_ptr< SingleMediaDownloader > d
Definition client.h:462
std::string name
Definition client.h:461
std::vector< u32 > tokens
Definition client.h:460
Definition inventorymanager.h:116
Definition inventorymanager.h:18
Definition item_visuals_manager.h:22
Definition clientmap.h:14
Definition mapnode.h:115
Describes a grid with given step, originating at (0,0,0).
Definition numeric.h:157
Definition mods.h:24
Definition mod_vfs.h:11
Definition player.h:45
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:73