22#include <unordered_set>
26#error Do not include in server builds
29#define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f
99 void print(std::ostream &o)
const;
114 const char *playername,
115 const std::string &password,
139 void connect(
const Address &address,
const std::string &address_name);
147 void step(
float dtime);
232 const std::string &newpassword);
245 const std::vector<ModSpec> &
getMods()
const override;
275 return m_env.getPlayerNames();
350 void drawLoadScreen(
const std::wstring &text,
float dtime,
int percent);
386 scene::IAnimatedMesh *
getMesh(
const std::string &filename,
bool *is_shared =
nullptr);
398 bool loadMedia(
const std::string &data,
const std::string &filename,
399 bool from_media_push =
false);
402 void request_media(
const std::vector<std::string> &file_requests);
440 const std::string &message)
override;
458 std::shared_ptr<SingleMediaDownloader>
d;
461 const std::shared_ptr<SingleMediaDownloader> &
d) :
name(
name),
d(
d)
483 void sendInit(
const std::string &playerName);
511 std::unique_ptr<con::IConnection>
m_con;
Definition clientenvironment.h:54
Definition scripting_client.h:27
bool m_skip_next_wield_animation
Definition client.h:525
void setFatalError(const std::string &reason)
Definition client.h:314
void handleCommand_NodeDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:744
void handleCommand_DeleteParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1148
ICraftDefManager * getCraftDefManager() override
Definition client.cpp:2005
void handleCommand_Privileges(NetworkPacket *pkt)
Definition clientpackethandler.cpp:901
bool activeObjectsReceived() const
Definition client.h:331
v3s16 getCrackPos()
Definition client.cpp:1706
std::unique_ptr< ModVFS > m_mod_vfs
Definition client.h:605
void loadMods()
Definition client.cpp:234
void handleCommand_AuthAccept(NetworkPacket *pkt)
Definition clientpackethandler.cpp:133
void clearOutChatQueue()
Definition client.cpp:1382
void handleCommand_ModChannelMsg(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1768
MtEventManager * getEventManager()
Definition client.cpp:2031
std::unique_ptr< ParticleManager > m_particle_manager
Definition client.h:510
void handleCommand_DetachedInventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:930
StringMap m_mesh_data
Definition client.h:590
bool loadMedia(const std::string &data, const std::string &filename, bool from_media_push=false)
Definition client.cpp:818
std::unordered_map< sound_handle_t, u16 > m_sounds_to_objects
Definition client.h:580
void handleCommand_AddNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:252
IItemDefManager * getItemDefManager() override
Definition client.cpp:1997
void sendHaveMedia(const std::vector< u32 > &tokens)
Definition client.cpp:1491
float m_connection_reinit_timer
Definition client.h:492
float m_inventory_from_server_age
Definition client.h:527
void handleCommand_DenySudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:183
void handleCommand_PlayerSpeed(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1689
const std::string & getFormspecPrepend() const
Definition client.cpp:2126
void interact(InteractAction action, const PointedThing &pointed)
Definition client.cpp:1115
ClientEnvironment & getEnv()
Definition client.h:239
void request_media(const std::vector< std::string > &file_requests)
Definition client.cpp:929
bool checkCSMRestrictionFlag(CSMRestrictionFlags flag) const
Definition client.h:432
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:1538
void handleCommand_AnnounceMedia(NetworkPacket *pkt)
Definition clientpackethandler.cpp:623
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:613
scene::ISceneManager * getSceneManager()
Definition client.cpp:1636
std::queue< ClientEvent * > m_client_event_queue
Definition client.h:557
const Address getServerAddress()
Definition client.cpp:1834
void handleCommand_HP(NetworkPacket *pkt)
Definition clientpackethandler.cpp:532
void handleCommand_UpdatePlayerList(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1616
void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1786
void handleCommand_ActiveObjectMessages(NetworkPacket *pkt)
Definition clientpackethandler.cpp:468
bool nodedefReceived() const
Definition client.h:327
void handleCommand_ItemDef(NetworkPacket *pkt)
Definition clientpackethandler.cpp:766
Camera * getCamera()
Definition client.h:365
IntervalLimiter m_map_timer_and_unload_interval
Definition client.h:496
float m_recommended_send_interval
Definition client.h:570
std::unordered_map< s32, sound_handle_t > m_sounds_server_to_client
Definition client.h:575
float m_avg_rtt_timer
Definition client.h:493
s32 m_mapblock_limit_logged
Definition client.h:528
float m_mod_storage_save_timer
Definition client.h:603
static const std::string & getBuiltinLuaPath()
Definition client.cpp:320
void handleCommand_ChatMessage(NetworkPacket *pkt)
Definition clientpackethandler.cpp:385
IntervalLimiter m_localdb_save_interval
Definition client.h:597
MeshGrid getMeshGrid()
Definition client.h:445
void sendRemovedSounds(const std::vector< s32 > &soundList)
Definition client.cpp:1271
void handleCommand_HudSetParam(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1337
void handleCommand_HudSetSky(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1359
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1798
NodeDefManager * m_nodedef
Definition client.h:501
void sendRespawnLegacy()
Definition client.cpp:1408
void sendUpdateClientInfo(const ClientDynamicInfo &info)
Definition client.cpp:1504
bool m_mods_loaded
Definition client.h:561
bool m_simple_singleplayer_mode
Definition client.h:339
void addNode(v3s16 p, MapNode n, bool remove_metadata=true)
Definition client.cpp:1575
void handleCommand_HudSetStars(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1490
u32 m_sudo_auth_methods
Definition client.h:540
void handleCommand_Movement(NetworkPacket *pkt)
Definition clientpackethandler.cpp:489
std::vector< std::string > m_remote_media_servers
Definition client.h:563
void setCamera(Camera *camera)
Definition client.h:363
void handleCommand_HudSetMoon(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1477
std::unordered_map< sound_handle_t, s32 > m_sounds_client_to_server
Definition client.h:578
float m_animation_time
Definition client.h:531
void pushToChatQueue(ChatMessage *cec)
Definition client.h:408
void setPlayerControl(PlayerControl &control)
Definition client.cpp:1593
u64 getMapSeed() const
Definition client.h:299
LocalClientState m_state
Definition client.h:593
std::unique_ptr< con::IConnection > m_con
Definition client.h:511
std::vector< ModSpec > m_mods
Definition client.h:604
Camera * m_camera
Definition client.h:514
void handleCommand_LocalPlayerAnimations(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1566
void sendInventoryFields(const std::string &formname, const StringMap &fields)
Definition client.cpp:1308
int m_crack_level
Definition client.h:532
std::unique_ptr< ClientMediaDownloader > m_media_downloader
Definition client.h:565
ItemVisualsManager * m_item_visuals_manager
Definition client.h:505
IWritableShaderSource * m_shsrc
Definition client.h:499
std::unordered_map< std::string, Inventory * > m_detached_inventories
Definition client.h:587
std::unique_ptr< MapDatabase > m_localdb
Definition client.h:596
void sendNodemetaFields(v3s16 p, const std::string &formname, const StringMap &fields)
Definition client.cpp:1286
void sendInit(const std::string &playerName)
Definition client.cpp:1186
void handleCommand_Hello(NetworkPacket *pkt)
Definition clientpackethandler.cpp:63
void deleteAuthData()
Definition client.cpp:1152
static AuthMechanism choseAuthMech(const u32 mechs)
Definition client.cpp:1172
bool hasClientEvents() const
Definition client.h:306
std::unique_ptr< Inventory > m_inventory_from_server
Definition client.h:526
void pushToEventQueue(ClientEvent *event)
Definition client.cpp:1990
std::string m_access_denied_reason
Definition client.h:556
bool itemdefReceived() const
Definition client.h:325
std::string m_password
Definition client.h:547
void inventoryAction(InventoryAction *a) override
Definition client.cpp:1685
std::string m_new_password
Definition client.h:549
void handleCommand_HudChange(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1250
Inventory * getInventory(const InventoryLocation &loc) override
Definition client.cpp:1641
const std::unordered_set< std::string > & getPrivilegeList() const
Definition client.h:293
void typeChatMessage(const std::wstring &message)
Definition client.cpp:1769
IWritableTextureSource * m_tsrc
Definition client.h:498
const std::set< std::string > & getConnectedPlayerNames()
Definition client.h:273
RenderingEngine * m_rendering_engine
Definition client.h:504
void Send(NetworkPacket *pkt)
Definition client.cpp:1074
float m_removed_sounds_check_timer
Definition client.h:573
std::unique_ptr< SSCSMController > m_sscsm_controller
Definition client.h:608
bool modsLoaded() const
Definition client.h:414
bool checkPrivilege(const std::string &priv) const
Definition client.h:290
void sendDamage(u16 damage)
Definition client.cpp:1401
void handleCommand_EyeOffset(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1586
std::queue< std::wstring > m_out_chat_queue
Definition client.h:534
u32 m_csm_restriction_noderange
Definition client.h:614
void handleCommand_FormspecPrepend(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1671
int CSMClampRadius(v3s16 pos, int radius)
Definition client.cpp:1550
ClientEvent * getClientEvent()
Definition client.cpp:1819
void handleCommand_SpawnParticleBatch(NetworkPacket *pkt)
Definition clientpackethandler.cpp:992
void makeScreenshot()
Definition client.cpp:1979
bool mediaReceived() const
Definition client.h:329
void handleCommand_MovePlayer(NetworkPacket *pkt)
Definition clientpackethandler.cpp:574
ISoundManager * m_sound
Definition client.h:502
void handleCommand_NodemetaChanged(NetworkPacket *pkt)
Definition clientpackethandler.cpp:269
std::string m_playername
Definition client.h:546
void sendDeletedBlocks(std::vector< v3s16 > &blocks)
Definition client.cpp:1248
IWritableItemDefManager * m_itemdef
Definition client.h:500
bool checkLocalPrivilege(const std::string &priv)
Definition client.h:380
virtual ISoundManager * getSoundManager()
Definition client.cpp:2027
void ProcessData(NetworkPacket *pkt)
Definition client.cpp:1029
bool sendModChannelMessage(const std::string &channel, const std::string &message) override
Definition client.cpp:2102
u16 getProtoVersion() const
Definition client.h:334
void handleCommand_PlaySound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:788
void startAuth(AuthMechanism chosen_auth_mechanism)
Definition client.cpp:1197
void handleCommand_Null(NetworkPacket *pkt)
Definition client.h:155
bool joinModChannel(const std::string &channel) override
Definition client.cpp:2076
void handleCommand_SrpBytesSandB(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1638
~Client()
Definition client.cpp:366
void handleCommand_MovePlayerRel(NetworkPacket *pkt)
Definition clientpackethandler.cpp:605
void removeNode(v3s16 p)
Definition client.cpp:1516
u64 getCSMRestrictionFlags() const
Definition client.h:427
u16 m_proto_ver
Definition client.h:522
bool canSendChatMessage() const
Definition client.cpp:1343
ISoundManager * sound()
Definition client.h:241
void loadSSCSM()
Definition client.cpp:1946
std::vector< PendingMediaDownload > m_pending_media_downloads
Definition client.h:567
void handleCommand_InventoryFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:920
bool consumeSkipNextWieldAnimation()
Definition client.cpp:1629
bool m_activeobjects_received
Definition client.h:560
void sendChangePassword(const std::string &oldpassword, const std::string &newpassword)
Definition client.cpp:1387
u16 allocateUnknownNodeId(const std::string &name) override
Definition client.cpp:2019
void handleCommand_Deprecated(NetworkPacket *pkt)
Definition clientpackethandler.cpp:56
void sendReady()
Definition client.cpp:1414
u8 m_server_ser_ver
Definition client.h:518
void handleCommand_HudSetFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1308
void step(float dtime)
Definition client.cpp:428
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:513
bool m_update_wielded_item
Definition client.h:524
float m_chat_message_allowance
Definition client.h:536
void sendPlayerPos()
Definition client.cpp:1427
void handleCommand_HudSetSun(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1464
void * m_auth_data
Definition client.h:552
PacketCounter m_packetcounter
Definition client.h:529
ItemVisualsManager * getItemVisualsManager()
Definition client.h:391
int getCrackLevel()
Definition client.cpp:1701
u16 getHP()
Definition client.cpp:1731
int m_playerpos_repeat_count
Definition client.h:495
void handleCommand_RemoveNode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:245
void sendChatMessage(const std::wstring &message)
Definition client.cpp:1357
void handleCommand_Breath(NetworkPacket *pkt)
Definition clientpackethandler.cpp:562
MeshGrid m_mesh_grid
Definition client.h:619
std::unique_ptr< MeshUpdateManager > m_mesh_update_manager
Definition client.h:508
void handleCommand_BlockData(NetworkPacket *pkt)
Definition clientpackethandler.cpp:295
std::unique_ptr< ModChannelMgr > m_modchannel_mgr
Definition client.h:616
void afterContentReceived()
Definition client.cpp:1884
void handleCommand_HudRemove(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1238
virtual IWritableShaderSource * getShaderSource()
Definition client.cpp:2014
bool m_internal_server
Definition client.h:346
float getCurRate()
Definition client.cpp:1972
void handleCommand_ActiveObjectRemoveAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:424
bool m_shutdown
Definition client.h:610
bool isShutdown()
Definition client.cpp:361
void handleCommand_Inventory(NetworkPacket *pkt)
Definition clientpackethandler.cpp:341
void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false)
Definition client.cpp:1803
ModStorageDatabase * m_mod_storage_database
Definition client.h:602
void handleCommand_OverrideDayNightRatio(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1550
bool m_nodedef_received
Definition client.h:559
u64 m_map_seed
Definition client.h:543
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:1856
bool m_itemdef_received
Definition client.h:558
void setPlayerItem(u16 item)
Definition client.cpp:1600
LocalClientState getState()
Definition client.h:404
scene::IAnimatedMesh * getMesh(const std::string &filename, bool *is_shared=nullptr)
Definition client.cpp:2041
void migrateModStorage()
Definition client.cpp:207
float getRTT()
Definition client.cpp:1966
float m_playerpos_send_timer
Definition client.h:494
ModChannel * getModChannel(const std::string &channel) override
Definition client.cpp:2121
bool m_access_denied
Definition client.h:554
bool inhibit_inventory_revert
Definition client.h:450
static const std::string & getClientModsLuaPath()
Definition client.cpp:326
Minimap * getMinimap()
Definition client.h:362
void handleCommand_AccessDenied(NetworkPacket *pkt)
Definition clientpackethandler.cpp:192
ITextureSource * getTextureSource()
Definition client.cpp:2010
void handleCommand_AddParticleSpawner(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1015
const std::string & getAddressName() const
Definition client.h:422
void handleCommand_DeathScreenLegacy(NetworkPacket *pkt)
Definition clientpackethandler.cpp:616
u16 m_cache_save_interval
Definition client.h:598
void handleCommand_ModChannelSignal(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1786
void handleCommand_CSMRestrictionFlags(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1680
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:916
bool leaveModChannel(const std::string &channel) override
Definition client.cpp:2089
bool hasServerReplied() const
Definition client.h:358
AuthMechanism m_chosen_auth_mech
Definition client.h:551
bool mediaReceiveProgress(s32 &received, s32 &total, size_t &received_size) const
Definition client.cpp:1839
std::queue< ChatMessage * > m_chat_queue
Definition client.h:537
std::unordered_set< std::string > m_privileges
Definition client.h:583
void handleCommand_Fov(NetworkPacket *pkt)
Definition clientpackethandler.cpp:513
void peerAdded(con::IPeer *peer) override
Definition client.cpp:910
void sendGotBlocks(const std::vector< v3s16 > &blocks)
Definition client.cpp:1261
MtEventManager * m_event
Definition client.h:503
void handleCommand_SetLighting(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1883
void handleCommand_MediaPush(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1700
void handleCommand(NetworkPacket *pkt)
Definition client.cpp:1020
void handleCommand_TimeOfDay(NetworkPacket *pkt)
Definition clientpackethandler.cpp:368
bool isClient() override
Definition client.h:369
void setCrack(int level, v3s16 pos)
Definition client.cpp:1711
bool m_access_denied_reconnect
Definition client.h:555
bool updateWieldedItem()
Definition client.cpp:1612
bool reconnectRequested() const
Definition client.h:312
void initLocalMapSaving(const Address &address, const std::string &hostname)
Definition client.cpp:952
const NodeDefManager * getNodeDefManager() override
Definition client.cpp:2001
ClientScripting * getScript()
Definition client.h:413
void handleCommand_AcceptSudoMode(NetworkPacket *pkt)
Definition clientpackethandler.cpp:168
std::unique_ptr< Minimap > m_minimap
Definition client.h:515
ModVFS * getModVFS()
Definition client.h:388
v3s16 m_crack_pos
Definition client.h:533
DISABLE_CLASS_COPY(Client)
bool getChatMessage(std::wstring &message)
Definition client.cpp:1738
ITextureSource * tsrc()
Definition client.h:240
float m_packetcounter_timer
Definition client.h:491
std::string m_address_name
Definition client.h:512
void drawLoadScreen(const std::wstring &text, float dtime, int percent)
Definition client.cpp:1849
ClientEnvironment m_env
Definition client.h:509
void ReceiveAll()
Definition client.cpp:983
void sendInventoryAction(InventoryAction *a)
Definition client.cpp:1328
void handleCommand_SpawnParticle(NetworkPacket *pkt)
Definition clientpackethandler.cpp:978
const std::string & accessDeniedReason() const
Definition client.h:323
void handleCommand_HudAdd(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1160
void handleCommand_ShowFormSpec(NetworkPacket *pkt)
Definition clientpackethandler.cpp:962
void handleCommand_CloudParams(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1515
u32 m_last_chat_message_sent
Definition client.h:535
void handleCommand_Media(NetworkPacket *pkt)
Definition clientpackethandler.cpp:688
float getAnimationTime() const
Definition client.h:278
virtual ParticleManager * getParticleManager()
Definition client.cpp:2036
v3s16 CSMClampPos(v3s16 pos)
Definition client.cpp:1562
void showUpdateProgressTexture(void *args, float progress)
Definition client.cpp:1860
void handleCommand_FadeSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:888
void handleCommand_Camera(NetworkPacket *pkt)
Definition clientpackethandler.cpp:1602
void handleCommand_StopSound(NetworkPacket *pkt)
Definition clientpackethandler.cpp:875
ClientScripting * m_script
Definition client.h:601
Definition craftdef.h:394
Definition texturesource.h:45
Definition texturesource.h:120
InventoryManager()=default
Definition inventory.h:277
Definition mesh_generator_thread.h:146
Definition modchannels.h:52
Definition modchannels.h:23
Definition networkpacket.h:16
This class is for getting the actual properties of nodes from their content ID.
Definition nodedef.h:514
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
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 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
Definition al_extensions.cpp:11
CSMRestrictionFlags
Definition networkprotocol.h:962
@ CSM_RF_NONE
Definition networkprotocol.h:963
InteractAction
Definition networkprotocol.h:978
AuthMechanism
Definition networkprotocol.h:924
std::unordered_map< std::string, std::string > StringMap
Definition string.h:66
Definition chatmessage.h:20
Definition clientdynamicinfo.h:12
Definition clientevent.h:70
Definition inventorymanager.h:116
Definition inventorymanager.h:18
Definition item_visuals_manager.h:22
Definition clientmap.h:14
Describes a grid with given step, originating at (0,0,0).
Definition numeric.h:157
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:66