Luanti 5.19.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 "lighting.h"
13#include "network/address.h"
14#include "network/networkprotocol.h" // multiple enums
15#include "network/peerhandler.h"
16#include "util/numeric.h"
17#include "util/string.h" // StringMap
18
19#include <map>
20#include <memory>
21#include <ostream>
22#include <set>
23#include <unordered_set>
24#include <vector>
25
26#if !IS_CLIENT_BUILD
27#error Do not include in server builds
28#endif
29
30#define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f
31
32class Camera;
34class ISoundManager;
38class LuaError;
39class MapDatabase;
41class Minimap;
42class ModChannelMgr;
43class MtEventManager;
44class NetworkPacket;
45class NodeDefManager;
46class ParticleManager;
47class RenderingEngine;
49class ClientScripting;
50class SSCSMController;
51struct ChatMessage;
53struct ClientEvent;
54struct MapDrawControl;
55struct MapNode;
56struct PlayerControl;
57struct PointedThing;
59struct ModVFS;
60
61namespace scene {
62class IAnimatedMesh;
63}
64
65namespace con {
66class IConnection;
67}
68using sound_handle_t = int;
69
75
76/*
77 Packet counter
78*/
79
81{
82public:
83 PacketCounter() = default;
84
85 void add(u16 command)
86 {
87 auto n = m_packets.find(command);
88 if (n == m_packets.end())
89 m_packets[command] = 1;
90 else
91 n->second++;
92 }
93
94 void clear()
95 {
96 m_packets.clear();
97 }
98
99 u32 sum() const;
100 void print(std::ostream &o) const;
101
102private:
103 // command, count
104 std::map<u16, u32> m_packets;
105};
106
107class Client : public con::PeerHandler, public InventoryManager, public IGameDef
108{
109public:
110 /*
111 NOTE: Nothing is thread-safe here.
112 */
113
114 Client(
115 const char *playername,
116 const std::string &password,
117 MapDrawControl &control,
121 NodeDefManager *nodedef,
123 MtEventManager *event,
124 RenderingEngine *rendering_engine,
125 ItemVisualsManager *item_visuals,
126 ELoginRegister allow_login_or_register
127 );
128
129 ~Client();
131
132 /*
133 request all threads managed by client to be stopped
134 */
135 void Stop();
136
137
138 bool isShutdown();
139
140 void connect(const Address &address, const std::string &address_name);
141
142 /*
143 Stuff that references the environment is valid only as
144 long as this is not called. (eg. Players)
145 If this throws a PeerNotFoundException, the connection has
146 timed out.
147 */
148 void step(float dtime);
149
150 /*
151 * Command Handlers
152 */
153
154 void handleCommand(NetworkPacket* pkt);
155
218
219 void ProcessData(NetworkPacket *pkt);
220
221 void Send(NetworkPacket* pkt);
222
223 void interact(InteractAction action, const PointedThing &pointed);
224
225 void sendNodemetaFields(v3s16 p, const std::string &formname,
226 const StringMap &fields);
227 void sendInventoryFields(const std::string &formname,
228 const StringMap &fields);
230 void sendChatMessage(const std::wstring &message);
231 void clearOutChatQueue();
232 void sendChangePassword(const std::string &oldpassword,
233 const std::string &newpassword);
234 void sendDamage(u16 damage);
235 void sendRespawnLegacy();
236 void sendReady();
237 void sendHaveMedia(const std::vector<u32> &tokens);
238 void sendUpdateClientInfo(const ClientDynamicInfo &info);
239
243 static const std::string &getBuiltinLuaPath();
244 static const std::string &getClientModsLuaPath();
245
246 const std::vector<ModSpec> &getMods() const override;
247 const ModSpec* getModSpec(const std::string &modname) const override;
248
249 // Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
250 void removeNode(v3s16 p);
251
252 // helpers to enforce CSM restrictions
253 MapNode CSMGetNode(v3s16 p, bool *is_valid_position);
254 int CSMClampRadius(v3s16 pos, int radius);
256
257 void addNode(v3s16 p, MapNode n, bool remove_metadata = true);
258
259 void setPlayerControl(PlayerControl &control);
260
261 // Returns true if the inventory of the local player has been
262 // updated from the server. If it is true, it is set to false.
263 bool updateWieldedItem();
264
266
267 /* InventoryManager interface */
268 Inventory* getInventory(const InventoryLocation &loc) override;
269 void inventoryAction(InventoryAction *a) override;
270
271 // Send the item number 'item' as player item to the server
272 void setPlayerItem(u16 item);
273
274 const std::set<std::string> &getConnectedPlayerNames()
275 {
276 return m_env.getPlayerNames();
277 }
278
279 float getAnimationTime() const
280 {
281 return m_animation_time;
282 }
283
285 int getCrackLevel();
287 void setCrack(int level, v3s16 pos);
288
289 u16 getHP();
290
291 bool checkPrivilege(const std::string &priv) const
292 { return (m_privileges.count(priv) != 0); }
293
294 const std::unordered_set<std::string> &getPrivilegeList() const
295 { return m_privileges; }
296
297 bool getChatMessage(std::wstring &message);
298 void typeChatMessage(const std::wstring& message);
299
300 u64 getMapSeed() const { return m_map_seed; }
301
302 void addUpdateMeshTask(v3s16 blockpos, bool urgent=false);
303 // Including blocks at appropriate edges
304 void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool urgent=false);
305 void addUpdateMeshTaskForNode(v3s16 nodepos, bool urgent=false);
306
307 bool hasClientEvents() const { return !m_client_event_queue.empty(); }
308 // Get event from queue. If queue is empty, it triggers an assertion failure.
310
311 bool accessDenied() const { return m_access_denied; }
312
314
315 void setFatalError(const std::string &reason)
316 {
317 m_access_denied = true;
318 m_access_denied_reason = reason;
319 }
320 void setFatalError(const LuaError &e);
321
322 // Renaming accessDeniedReason to better name could be good as it's used to
323 // disconnect client when CSM failed.
324 const std::string &accessDeniedReason() const { return m_access_denied_reason; }
325
326 bool itemdefReceived() const
327 { return m_itemdef_received; }
328 bool nodedefReceived() const
329 { return m_nodedef_received; }
330 bool mediaReceived() const
331 { return !m_media_downloader; }
334
335 u16 getProtoVersion() const
336 { return m_proto_ver; }
337
338 // Whether the server is in "simple singleplayer mode".
339 // This implies "m_internal_server = true".
341
342 // Whether the server is hosted by the same Luanti instance and singletons
343 // like g_settings are shared between client and server.
344 //
345 // This is intentionally *not* true if we're just connecting to a localhost
346 // server hosted by a different Luanti instance.
348
349 bool mediaReceiveProgress(s32 &received, s32 &total, size_t &received_size) const;
350
351 void drawLoadScreen(const std::wstring &text, float dtime, int percent);
353 void loadSSCSM();
354 void showUpdateProgressTexture(void *args, float progress);
355
356 float getRTT();
357 float getCurRate();
358 // has the server ever replied to us, used for connection retry/fallback
359 bool hasServerReplied() const {
360 return getProtoVersion() != 0; // (set in TOCLIENT_HELLO)
361 }
362
363 Minimap* getMinimap() { return m_minimap.get(); }
364 void setCamera(Camera* camera) { m_camera = camera; }
365
366 Camera* getCamera () { return m_camera; }
367 scene::ISceneManager *getSceneManager();
368
369 // IGameDef interface
370 bool isClient() override { return true; }
372 const NodeDefManager* getNodeDefManager() override;
376 u16 allocateUnknownNodeId(const std::string &name) override;
380
381 bool checkLocalPrivilege(const std::string &priv)
382 { return checkPrivilege(priv); }
383
384 // Gets a pointer to a named mesh
385 // If you want to modify it, you may need to clone it first (-> `is_shared`)
386 // (the returned pointer must be dropped)
387 scene::IAnimatedMesh *getMesh(const std::string &filename, bool *is_shared = nullptr);
388
389 ModVFS *getModVFS() { return m_mod_vfs.get(); }
391
393
394 // Migrates away old files-based mod storage if necessary
395 void migrateModStorage();
396
397 // The following set of functions is used by ClientMediaDownloader
398 // Insert a media file appropriately into the appropriate manager
399 bool loadMedia(const std::string &data, const std::string &filename,
400 bool from_media_push = false);
401
402 // Send a request for conventional media transfer
403 void requestMedia(const std::vector<std::string> &file_requests);
404
406
407 // Request a screenshot to be taken at the end of the frame.
409
410 // Must be called right before endScene() to take requested screenshots.
412
413 inline void pushToChatQueue(ChatMessage *cec)
414 {
415 m_chat_queue.push(cec);
416 }
417
419 bool modsLoaded() const { return m_mods_loaded; }
420
421 void pushToEventQueue(ClientEvent *event);
422
423 // IP and port we're connected to
425
426 // Hostname of the connected server (but can also be a numerical IP)
427 const std::string &getAddressName() const
428 {
429 return m_address_name;
430 }
431
432 inline u64 getCSMRestrictionFlags() const
433 {
435 }
436
438 {
439 return m_csm_restriction_flags & flag;
440 }
441
442 bool joinModChannel(const std::string &channel) override;
443 bool leaveModChannel(const std::string &channel) override;
444 bool sendModChannelMessage(const std::string &channel,
445 const std::string &message) override;
446 ModChannel *getModChannel(const std::string &channel) override;
447
448 const std::string &getFormspecPrepend() const;
449
450 inline MeshGrid getMeshGrid() const
451 {
452 return m_mesh_grid;
453 }
454
456 {
458 }
459
461
462private:
464 // Tokens to ack to the server. multiple because server can send duplicate
465 // requests
466 std::vector<u32> tokens;
467 std::string name; // Filename
468 std::shared_ptr<SingleMediaDownloader> d;
469
470 PendingMediaDownload(u32 token, const std::string &name,
471 const std::shared_ptr<SingleMediaDownloader> &d) : name(name), d(d)
472 {
473 tokens.push_back(token);
474 }
475 };
476
477 void loadMods();
478
479 // Virtual methods from con::PeerHandler
480 void peerAdded(con::IPeer *peer) override;
481 void deletingPeer(con::IPeer *peer, bool timeout) override;
482
483 void initLocalMapSaving(const Address &address, const std::string &hostname);
484
485 void ReceiveAll();
486
487 void deleteAuthData();
488 // helper method shared with clientpackethandler
489 static AuthMechanism choseAuthMech(const u32 mechs);
490
491 void sendInit(const std::string &playerName);
492 void startAuth(AuthMechanism chosen_auth_mechanism);
493 void sendDeletedBlocks(const std::vector<v3s16> &blocks);
494 void sendGotBlocks(const std::vector<v3s16> &blocks);
495 void sendRemovedSounds(const std::vector<s32> &soundList);
496 void sendPlayerPos();
497
498 bool updateStaticLighting(const StaticLighting &future);
499
500 bool canSendChatMessage() const;
501
504 float m_avg_rtt_timer = 0.0f;
508
517
518 std::unique_ptr<MeshUpdateManager> m_mesh_update_manager;
520 std::unique_ptr<ParticleManager> m_particle_manager;
521 std::unique_ptr<con::IConnection> m_con;
522 std::string m_address_name;
524 Camera *m_camera = nullptr;
525 std::unique_ptr<Minimap> m_minimap;
526
527 // Server serialization version
529
530 // Used version of the protocol with server
531 // If 0, server init hasn't been received yet.
532 u16 m_proto_ver = 0;
533
536 std::unique_ptr<Inventory> m_inventory_from_server;
540 // Block mesh animation parameters
541 float m_animation_time = 0.0f;
544 std::queue<std::wstring> m_out_chat_queue;
547 std::queue<ChatMessage *> m_chat_queue;
550 std::vector<v3s16> m_got_blocks;
551
552 // The authentication methods we can use to enter sudo mode (=change password)
554
555 // The seed returned by the server in TOCLIENT_AUTH_ACCEPT is stored here
556 u64 m_map_seed = 0;
557
558 // The number of blocks the client will combine for mesh generation.
560
561 // The static lighting currently in use
563
564 // Auth data
565 std::string m_playername;
566 std::string m_password;
567 // If set, this will be sent (and cleared) upon a TOCLIENT_ACCEPT_SUDO_MODE
568 std::string m_new_password;
569 // Usable by auth mechanisms.
571 void *m_auth_data = nullptr;
572
573 bool m_access_denied = false;
575 std::string m_access_denied_reason = "";
576 std::queue<ClientEvent *> m_client_event_queue;
577 bool m_itemdef_received = false;
578 bool m_nodedef_received = false;
580 bool m_mods_loaded = false;
581
582 std::vector<std::string> m_remote_media_servers;
583 // Media downloader, only exists during init
584 std::unique_ptr<ClientMediaDownloader> m_media_downloader;
585 // Pending downloads of dynamic media
586 std::vector<PendingMediaDownload> m_pending_media_downloads;
587
588 // An interval for generally sending object positions and stuff
590
591 // Sounds
593 // Mapping from server sound ids to our sound ids
594 std::unordered_map<s32, sound_handle_t> m_sounds_server_to_client;
595 // And the other way!
596 // This takes ownership for the sound handles.
597 std::unordered_map<sound_handle_t, s32> m_sounds_client_to_server;
598 // Relation of client id to object id
599 std::unordered_map<sound_handle_t, u16> m_sounds_to_objects;
600
601 // Privileges
602 std::unordered_set<std::string> m_privileges;
603
604 // Detached inventories
605 // key = name
606 std::unordered_map<std::string, Inventory*> m_detached_inventories;
607
608 // Storage for mesh data for creating multiple instances of the same mesh
610
611 // own state
613
614 // Used for saving server map to disk client-side
615 std::unique_ptr<MapDatabase> m_localdb;
618
619 // Client modding
623 std::vector<ModSpec> m_mods;
624 std::unique_ptr<ModVFS> m_mod_vfs;
625
626 // SSCSM
627 std::unique_ptr<SSCSMController> m_sscsm_controller;
628
629 bool m_shutdown = false;
630 bool m_take_screenshot = false;
631
632 // CSM restrictions byteflag
635
636 std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
637};
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
bool m_skip_next_wield_animation
Definition client.h:535
void setFatalError(const std::string &reason)
Definition client.h:315
void handleCommand_NodeDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:751
void handleCommand_DeleteParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1155
ICraftDefManager * getCraftDefManager() override
Definition client.cpp:2017
const StaticLighting & getCommittedStaticLighting() const
Definition client.h:455
void handleCommand_Privileges(NetworkPacket *pkt)
Definition clientpackethandler.cpp:908
bool activeObjectsReceived() const
Definition client.h:332
v3s16 getCrackPos()
Definition client.cpp:1715
std::unique_ptr< ModVFS > m_mod_vfs
Definition client.h:624
void loadMods()
Definition client.cpp:233
void handleCommand_AuthAccept(NetworkPacket *pkt)
Definition clientpackethandler.cpp:134
void clearOutChatQueue()
Definition client.cpp:1391
void handleCommand_ModChannelMsg(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1775
MtEventManager * getEventManager()
Definition client.cpp:2043
std::unique_ptr< ParticleManager > m_particle_manager
Definition client.h:520
void handleCommand_DetachedInventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:937
StringMap m_mesh_data
Definition client.h:609
bool loadMedia(const std::string &data, const std::string &filename, bool from_media_push=false)
Definition client.cpp:821
std::unordered_map< sound_handle_t, u16 > m_sounds_to_objects
Definition client.h:599
void handleCommand_AddNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:248
void sendDeletedBlocks(const std::vector< v3s16 > &blocks)
Definition client.cpp:1256
IItemDefManager * getItemDefManager() override
Definition client.cpp:2009
void sendHaveMedia(const std::vector< u32 > &tokens)
Definition client.cpp:1500
float m_connection_reinit_timer
Definition client.h:503
float m_inventory_from_server_age
Definition client.h:537
void handleCommand_DenySudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:179
void handleCommand_PlayerSpeed(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1696
const std::string & getFormspecPrepend() const
Definition client.cpp:2138
void interact(InteractAction action, const PointedThing &pointed)
Definition client.cpp:1123
ClientEnvironment & getEnv()
Definition client.h:240
bool checkCSMRestrictionFlag(CSMRestrictionFlags flag) const
Definition client.h:437
void Stop()
Definition client.cpp:342
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:1547
void handleCommand_AnnounceMedia(NetworkPacket *pkt)
Definition clientpackethandler.cpp:630
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool urgent=false)
Definition client.cpp:1807
bool updateStaticLighting(const StaticLighting &future)
Definition client.cpp:796
ModStorageDatabase * getModStorageDatabase() override
Definition client.h:390
const ModSpec * getModSpec(const std::string &modname) const override
Definition client.cpp:337
u64 m_csm_restriction_flags
Definition client.h:633
scene::ISceneManager * getSceneManager()
Definition client.cpp:1645
std::queue< ClientEvent * > m_client_event_queue
Definition client.h:576
const Address getServerAddress()
Definition client.cpp:1843
void handleCommand_HP(NetworkPacket *pkt)
Definition clientpackethandler.cpp:539
void handleCommand_UpdatePlayerList(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1623
void handleCommand_ActiveObjectMessages(NetworkPacket *pkt)
Definition clientpackethandler.cpp:475
bool nodedefReceived() const
Definition client.h:328
void handleCommand_ItemDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:773
Camera * getCamera()
Definition client.h:366
IntervalLimiter m_map_timer_and_unload_interval
Definition client.h:507
float m_recommended_send_interval
Definition client.h:589
std::unordered_map< s32, sound_handle_t > m_sounds_server_to_client
Definition client.h:594
float m_avg_rtt_timer
Definition client.h:504
StaticLighting m_committed_static_light
Definition client.h:562
s32 m_mapblock_limit_logged
Definition client.h:538
float m_mod_storage_save_timer
Definition client.h:622
static const std::string & getBuiltinLuaPath()
Definition client.cpp:319
void handleCommand_ChatMessage(NetworkPacket *pkt)
Definition clientpackethandler.cpp:392
IntervalLimiter m_localdb_save_interval
Definition client.h:616
void sendRemovedSounds(const std::vector< s32 > &soundList)
Definition client.cpp:1280
void handleCommand_HudSetParam(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1344
void handleCommand_HudSetSky(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1366
NodeDefManager * m_nodedef
Definition client.h:512
void sendRespawnLegacy()
Definition client.cpp:1417
void sendUpdateClientInfo(const ClientDynamicInfo &info)
Definition client.cpp:1513
bool m_mods_loaded
Definition client.h:580
void takeScreenshotIfRequested()
Definition client.cpp:1987
bool m_simple_singleplayer_mode
Definition client.h:340
void addNode(v3s16 p, MapNode n, bool remove_metadata=true)
Definition client.cpp:1584
void handleCommand_HudSetStars(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1497
u32 m_sudo_auth_methods
Definition client.h:553
bool m_take_screenshot
Definition client.h:630
void handleCommand_Movement(NetworkPacket *pkt)
Definition clientpackethandler.cpp:496
std::vector< std::string > m_remote_media_servers
Definition client.h:582
void setCamera(Camera *camera)
Definition client.h:364
void handleCommand_HudSetMoon(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1484
std::unordered_map< sound_handle_t, s32 > m_sounds_client_to_server
Definition client.h:597
float m_animation_time
Definition client.h:541
void pushToChatQueue(ChatMessage *cec)
Definition client.h:413
void setPlayerControl(PlayerControl &control)
Definition client.cpp:1602
u64 getMapSeed() const
Definition client.h:300
LocalClientState m_state
Definition client.h:612
std::unique_ptr< con::IConnection > m_con
Definition client.h:521
std::vector< ModSpec > m_mods
Definition client.h:623
Camera * m_camera
Definition client.h:524
void handleCommand_LocalPlayerAnimations(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1573
void sendInventoryFields(const std::string &formname, const StringMap &fields)
Definition client.cpp:1317
int m_crack_level
Definition client.h:542
std::unique_ptr< ClientMediaDownloader > m_media_downloader
Definition client.h:584
ItemVisualsManager * m_item_visuals_manager
Definition client.h:516
IWritableShaderSource * m_shsrc
Definition client.h:510
std::unordered_map< std::string, Inventory * > m_detached_inventories
Definition client.h:606
std::unique_ptr< MapDatabase > m_localdb
Definition client.h:615
void sendNodemetaFields(v3s16 p, const std::string &formname, const StringMap &fields)
Definition client.cpp:1295
void sendInit(const std::string &playerName)
Definition client.cpp:1194
void handleCommand_Hello(NetworkPacket *pkt)
Definition clientpackethandler.cpp:63
void deleteAuthData()
Definition client.cpp:1160
static AuthMechanism choseAuthMech(const u32 mechs)
Definition client.cpp:1180
bool hasClientEvents() const
Definition client.h:307
std::unique_ptr< Inventory > m_inventory_from_server
Definition client.h:536
void pushToEventQueue(ClientEvent *event)
Definition client.cpp:2002
std::string m_access_denied_reason
Definition client.h:575
bool itemdefReceived() const
Definition client.h:326
std::string m_password
Definition client.h:566
void inventoryAction(InventoryAction *a) override
Definition client.cpp:1694
std::string m_new_password
Definition client.h:568
void handleCommand_HudChange(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1257
Inventory * getInventory(const InventoryLocation &loc) override
Definition client.cpp:1650
const std::unordered_set< std::string > & getPrivilegeList() const
Definition client.h:294
void typeChatMessage(const std::wstring &message)
Definition client.cpp:1778
IWritableTextureSource * m_tsrc
Definition client.h:509
const std::set< std::string > & getConnectedPlayerNames()
Definition client.h:274
RenderingEngine * m_rendering_engine
Definition client.h:515
void Send(NetworkPacket *pkt)
Definition client.cpp:1082
float m_removed_sounds_check_timer
Definition client.h:592
std::unique_ptr< SSCSMController > m_sscsm_controller
Definition client.h:627
bool modsLoaded() const
Definition client.h:419
bool checkPrivilege(const std::string &priv) const
Definition client.h:291
void sendDamage(u16 damage)
Definition client.cpp:1410
void handleCommand_EyeOffset(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1593
std::queue< std::wstring > m_out_chat_queue
Definition client.h:544
u32 m_csm_restriction_noderange
Definition client.h:634
void addUpdateMeshTask(v3s16 blockpos, bool urgent=false)
Definition client.cpp:1795
void handleCommand_FormspecPrepend(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1678
int CSMClampRadius(v3s16 pos, int radius)
Definition client.cpp:1559
ClientEvent * getClientEvent()
Definition client.cpp:1828
void handleCommand_SpawnParticleBatch(NetworkPacket *pkt)
Definition clientpackethandler.cpp:999
bool mediaReceived() const
Definition client.h:330
void handleCommand_MovePlayer(NetworkPacket *pkt)
Definition clientpackethandler.cpp:581
ISoundManager * m_sound
Definition client.h:513
void handleCommand_NodemetaChanged(NetworkPacket *pkt)
Definition clientpackethandler.cpp:265
std::string m_playername
Definition client.h:565
IWritableItemDefManager * m_itemdef
Definition client.h:511
bool checkLocalPrivilege(const std::string &priv)
Definition client.h:381
virtual ISoundManager * getSoundManager()
Definition client.cpp:2039
void ProcessData(NetworkPacket *pkt)
Definition client.cpp:1037
bool sendModChannelMessage(const std::string &channel, const std::string &message) override
Definition client.cpp:2114
u16 getProtoVersion() const
Definition client.h:335
void handleCommand_PlaySound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:795
void startAuth(AuthMechanism chosen_auth_mechanism)
Definition client.cpp:1205
void handleCommand_Null(NetworkPacket *pkt)
Definition client.h:156
bool joinModChannel(const std::string &channel) override
Definition client.cpp:2088
void requestScreenshot()
Definition client.h:408
void handleCommand_SrpBytesSandB(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1645
void handleCommand_MovePlayerRel(NetworkPacket *pkt)
Definition clientpackethandler.cpp:612
void removeNode(v3s16 p)
Definition client.cpp:1525
u64 getCSMRestrictionFlags() const
Definition client.h:432
void requestMedia(const std::vector< std::string > &file_requests)
Definition client.cpp:936
u16 m_proto_ver
Definition client.h:532
bool canSendChatMessage() const
Definition client.cpp:1352
ISoundManager * sound()
Definition client.h:242
void loadSSCSM()
Definition client.cpp:1954
std::vector< PendingMediaDownload > m_pending_media_downloads
Definition client.h:586
void handleCommand_InventoryFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:927
bool consumeSkipNextWieldAnimation()
Definition client.cpp:1638
bool m_activeobjects_received
Definition client.h:579
void sendChangePassword(const std::string &oldpassword, const std::string &newpassword)
Definition client.cpp:1396
u16 allocateUnknownNodeId(const std::string &name) override
Definition client.cpp:2031
void handleCommand_Deprecated(NetworkPacket *pkt)
Definition clientpackethandler.cpp:56
void sendReady()
Definition client.cpp:1423
u8 m_server_ser_ver
Definition client.h:528
void handleCommand_HudSetFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1315
void step(float dtime)
Definition client.cpp:429
bool accessDenied() const
Definition client.h:311
const std::vector< ModSpec > & getMods() const override
Definition client.cpp:331
ELoginRegister m_allow_login_or_register
Definition client.h:523
bool m_update_wielded_item
Definition client.h:534
float m_chat_message_allowance
Definition client.h:546
void sendPlayerPos()
Definition client.cpp:1436
void handleCommand_HudSetSun(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1471
void * m_auth_data
Definition client.h:571
PacketCounter m_packetcounter
Definition client.h:539
ItemVisualsManager * getItemVisualsManager()
Definition client.h:392
int getCrackLevel()
Definition client.cpp:1710
u16 getHP()
Definition client.cpp:1740
int m_playerpos_repeat_count
Definition client.h:506
void handleCommand_RemoveNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:241
void sendChatMessage(const std::wstring &message)
Definition client.cpp:1366
void handleCommand_Breath(NetworkPacket *pkt)
Definition clientpackethandler.cpp:569
std::vector< v3s16 > m_got_blocks
received blocks that we still want to ack to the server
Definition client.h:550
MeshGrid m_mesh_grid
Definition client.h:559
std::unique_ptr< MeshUpdateManager > m_mesh_update_manager
Definition client.h:518
void handleCommand_BlockData(NetworkPacket *pkt)
Definition clientpackethandler.cpp:291
std::unique_ptr< ModChannelMgr > m_modchannel_mgr
Definition client.h:636
void afterContentReceived()
Definition client.cpp:1893
void handleCommand_HudRemove(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1245
virtual IWritableShaderSource * getShaderSource()
Definition client.cpp:2026
bool m_internal_server
Definition client.h:347
float getCurRate()
Definition client.cpp:1980
void handleCommand_ActiveObjectRemoveAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:431
bool m_shutdown
Definition client.h:629
bool isShutdown()
Definition client.cpp:360
void handleCommand_Inventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:348
ModStorageDatabase * m_mod_storage_database
Definition client.h:621
void handleCommand_OverrideDayNightRatio(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1557
bool m_nodedef_received
Definition client.h:578
u64 m_map_seed
Definition client.h:556
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:127
void handleCommand_MinimapModes(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1864
bool m_itemdef_received
Definition client.h:577
void setPlayerItem(u16 item)
Definition client.cpp:1609
scene::IAnimatedMesh * getMesh(const std::string &filename, bool *is_shared=nullptr)
Definition client.cpp:2053
void migrateModStorage()
Definition client.cpp:206
float getRTT()
Definition client.cpp:1974
float m_playerpos_send_timer
Definition client.h:505
ModChannel * getModChannel(const std::string &channel) override
Definition client.cpp:2133
bool m_access_denied
Definition client.h:573
bool inhibit_inventory_revert
Definition client.h:460
LocalClientState getState() const
Definition client.h:405
static const std::string & getClientModsLuaPath()
Definition client.cpp:325
Minimap * getMinimap()
Definition client.h:363
void handleCommand_AccessDenied(NetworkPacket *pkt)
Definition clientpackethandler.cpp:188
void addUpdateMeshTaskForNode(v3s16 nodepos, bool urgent=false)
Definition client.cpp:1812
ITextureSource * getTextureSource()
Definition client.cpp:2022
void handleCommand_AddParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1022
const std::string & getAddressName() const
Definition client.h:427
void handleCommand_DeathScreenLegacy(NetworkPacket *pkt)
Definition clientpackethandler.cpp:623
u16 m_cache_save_interval
Definition client.h:617
void handleCommand_ModChannelSignal(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1794
void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1687
void connect(const Address &address, const std::string &address_name)
Definition client.cpp:404
void deletingPeer(con::IPeer *peer, bool timeout) override
Definition client.cpp:923
bool leaveModChannel(const std::string &channel) override
Definition client.cpp:2101
bool hasServerReplied() const
Definition client.h:359
MeshGrid getMeshGrid() const
Definition client.h:450
AuthMechanism m_chosen_auth_mech
Definition client.h:570
bool mediaReceiveProgress(s32 &received, s32 &total, size_t &received_size) const
Definition client.cpp:1848
std::queue< ChatMessage * > m_chat_queue
Definition client.h:547
std::unordered_set< std::string > m_privileges
Definition client.h:602
void handleCommand_Fov(NetworkPacket *pkt)
Definition clientpackethandler.cpp:520
void peerAdded(con::IPeer *peer) override
Definition client.cpp:917
void sendGotBlocks(const std::vector< v3s16 > &blocks)
Definition client.cpp:1268
MtEventManager * m_event
Definition client.h:514
void handleCommand_SetLighting(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1891
void handleCommand_MediaPush(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1707
void handleCommand(NetworkPacket *pkt)
Definition client.cpp:1028
void handleCommand_TimeOfDay(NetworkPacket *pkt)
Definition clientpackethandler.cpp:375
bool isClient() override
Definition client.h:370
void setCrack(int level, v3s16 pos)
Definition client.cpp:1720
bool m_access_denied_reconnect
Definition client.h:574
bool updateWieldedItem()
Definition client.cpp:1621
bool reconnectRequested() const
Definition client.h:313
void initLocalMapSaving(const Address &address, const std::string &hostname)
Definition client.cpp:959
const NodeDefManager * getNodeDefManager() override
Definition client.cpp:2013
ClientScripting * getScript()
Definition client.h:418
void handleCommand_AcceptSudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:164
std::unique_ptr< Minimap > m_minimap
Definition client.h:525
ModVFS * getModVFS()
Definition client.h:389
v3s16 m_crack_pos
Definition client.h:543
DISABLE_CLASS_COPY(Client)
bool getChatMessage(std::wstring &message)
Definition client.cpp:1747
ITextureSource * tsrc()
Definition client.h:241
float m_packetcounter_timer
Definition client.h:502
std::string m_address_name
Definition client.h:522
void drawLoadScreen(const std::wstring &text, float dtime, int percent)
Definition client.cpp:1858
ClientEnvironment m_env
Definition client.h:519
void ReceiveAll()
Definition client.cpp:990
void sendInventoryAction(InventoryAction *a)
Definition client.cpp:1337
void handleCommand_SpawnParticle(NetworkPacket *pkt)
Definition clientpackethandler.cpp:985
const std::string & accessDeniedReason() const
Definition client.h:324
void handleCommand_HudAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1167
void handleCommand_ShowFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:969
void handleCommand_CloudParams(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1522
u32 m_last_chat_message_sent
Definition client.h:545
void handleCommand_Media(NetworkPacket *pkt)
Definition clientpackethandler.cpp:695
float getAnimationTime() const
Definition client.h:279
virtual ParticleManager * getParticleManager()
Definition client.cpp:2048
v3s16 CSMClampPos(v3s16 pos)
Definition client.cpp:1571
void showUpdateProgressTexture(void *args, float progress)
Definition client.cpp:1869
void handleCommand_FadeSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:895
void handleCommand_Camera(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1609
void handleCommand_StopSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:882
ClientScripting * m_script
Definition client.h:620
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:419
InventoryManager()=default
Definition inventory.h:280
Definition c_types.h:32
Definition database.h:28
Definition mesh_generator_thread.h:157
Definition minimap.h:118
Definition modchannels.h:53
Definition modchannels.h:24
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:81
std::map< u16, u32 > m_packets
Definition client.h:104
void print(std::ostream &o) const
Definition client.cpp:92
void add(u16 command)
Definition client.h:85
PacketCounter()=default
u32 sum() const
Definition client.cpp:84
void clear()
Definition client.h:94
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:70
@ LC_Init
Definition client.h:72
@ LC_Created
Definition client.h:71
@ LC_Ready
Definition client.h:73
int sound_handle_t
IDs for playing sounds.
Definition client.h:68
ELoginRegister
Definition gameparams.h:23
@ Any
Definition gameparams.h:24
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
Definition client.h:65
Definition camera.h:24
Definition al_extensions.cpp:11
CSMRestrictionFlags
Definition networkprotocol.h:968
@ CSM_RF_NONE
Definition networkprotocol.h:969
InteractAction
Definition networkprotocol.h:984
AuthMechanism
Definition networkprotocol.h:930
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:470
std::shared_ptr< SingleMediaDownloader > d
Definition client.h:468
std::string name
Definition client.h:467
std::vector< u32 > tokens
Definition client.h:466
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
Definition lighting.h:51