client.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef CLIENT_HEADER
  17. #define CLIENT_HEADER
  18. #include "network/connection.h"
  19. #include "clientenvironment.h"
  20. #include "irrlichttypes_extrabloated.h"
  21. #include <ostream>
  22. #include <map>
  23. #include <set>
  24. #include <vector>
  25. #include <unordered_set>
  26. #include "clientobject.h"
  27. #include "gamedef.h"
  28. #include "inventorymanager.h"
  29. #include "localplayer.h"
  30. #include "hud.h"
  31. #include "particles.h"
  32. #include "mapnode.h"
  33. #include "tileanimation.h"
  34. #include "mesh_generator_thread.h"
  35. #define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f
  36. struct MeshMakeData;
  37. class MapBlockMesh;
  38. class IWritableTextureSource;
  39. class IWritableShaderSource;
  40. class IWritableItemDefManager;
  41. class IWritableNodeDefManager;
  42. //class IWritableCraftDefManager;
  43. class ClientMediaDownloader;
  44. struct MapDrawControl;
  45. class MtEventManager;
  46. struct PointedThing;
  47. class MapDatabase;
  48. class Minimap;
  49. struct MinimapMapblock;
  50. class Camera;
  51. class NetworkPacket;
  52. enum LocalClientState {
  53. LC_Created,
  54. LC_Init,
  55. LC_Ready
  56. };
  57. enum ClientEventType
  58. {
  59. CE_NONE,
  60. CE_PLAYER_DAMAGE,
  61. CE_PLAYER_FORCE_MOVE,
  62. CE_DEATHSCREEN,
  63. CE_SHOW_FORMSPEC,
  64. CE_SHOW_LOCAL_FORMSPEC,
  65. CE_SPAWN_PARTICLE,
  66. CE_ADD_PARTICLESPAWNER,
  67. CE_DELETE_PARTICLESPAWNER,
  68. CE_HUDADD,
  69. CE_HUDRM,
  70. CE_HUDCHANGE,
  71. CE_SET_SKY,
  72. CE_OVERRIDE_DAY_NIGHT_RATIO,
  73. CE_CLOUD_PARAMS,
  74. };
  75. struct ClientEvent
  76. {
  77. ClientEventType type;
  78. union{
  79. //struct{
  80. //} none;
  81. struct{
  82. u8 amount;
  83. } player_damage;
  84. struct{
  85. f32 pitch;
  86. f32 yaw;
  87. } player_force_move;
  88. struct{
  89. bool set_camera_point_target;
  90. f32 camera_point_target_x;
  91. f32 camera_point_target_y;
  92. f32 camera_point_target_z;
  93. } deathscreen;
  94. struct{
  95. std::string *formspec;
  96. std::string *formname;
  97. } show_formspec;
  98. //struct{
  99. //} textures_updated;
  100. struct{
  101. v3f *pos;
  102. v3f *vel;
  103. v3f *acc;
  104. f32 expirationtime;
  105. f32 size;
  106. bool collisiondetection;
  107. bool collision_removal;
  108. bool vertical;
  109. std::string *texture;
  110. struct TileAnimationParams animation;
  111. u8 glow;
  112. } spawn_particle;
  113. struct{
  114. u16 amount;
  115. f32 spawntime;
  116. v3f *minpos;
  117. v3f *maxpos;
  118. v3f *minvel;
  119. v3f *maxvel;
  120. v3f *minacc;
  121. v3f *maxacc;
  122. f32 minexptime;
  123. f32 maxexptime;
  124. f32 minsize;
  125. f32 maxsize;
  126. bool collisiondetection;
  127. bool collision_removal;
  128. u16 attached_id;
  129. bool vertical;
  130. std::string *texture;
  131. u32 id;
  132. struct TileAnimationParams animation;
  133. u8 glow;
  134. } add_particlespawner;
  135. struct{
  136. u32 id;
  137. } delete_particlespawner;
  138. struct{
  139. u32 id;
  140. u8 type;
  141. v2f *pos;
  142. std::string *name;
  143. v2f *scale;
  144. std::string *text;
  145. u32 number;
  146. u32 item;
  147. u32 dir;
  148. v2f *align;
  149. v2f *offset;
  150. v3f *world_pos;
  151. v2s32 * size;
  152. } hudadd;
  153. struct{
  154. u32 id;
  155. } hudrm;
  156. struct{
  157. u32 id;
  158. HudElementStat stat;
  159. v2f *v2fdata;
  160. std::string *sdata;
  161. u32 data;
  162. v3f *v3fdata;
  163. v2s32 * v2s32data;
  164. } hudchange;
  165. struct{
  166. video::SColor *bgcolor;
  167. std::string *type;
  168. std::vector<std::string> *params;
  169. bool clouds;
  170. } set_sky;
  171. struct{
  172. bool do_override;
  173. float ratio_f;
  174. } override_day_night_ratio;
  175. struct {
  176. f32 density;
  177. u32 color_bright;
  178. u32 color_ambient;
  179. f32 height;
  180. f32 thickness;
  181. f32 speed_x;
  182. f32 speed_y;
  183. } cloud_params;
  184. };
  185. };
  186. /*
  187. Packet counter
  188. */
  189. class PacketCounter
  190. {
  191. public:
  192. PacketCounter()
  193. {
  194. }
  195. void add(u16 command)
  196. {
  197. std::map<u16, u16>::iterator n = m_packets.find(command);
  198. if(n == m_packets.end())
  199. {
  200. m_packets[command] = 1;
  201. }
  202. else
  203. {
  204. n->second++;
  205. }
  206. }
  207. void clear()
  208. {
  209. for(std::map<u16, u16>::iterator
  210. i = m_packets.begin();
  211. i != m_packets.end(); ++i)
  212. {
  213. i->second = 0;
  214. }
  215. }
  216. void print(std::ostream &o)
  217. {
  218. for(std::map<u16, u16>::iterator
  219. i = m_packets.begin();
  220. i != m_packets.end(); ++i)
  221. {
  222. o<<"cmd "<<i->first
  223. <<" count "<<i->second
  224. <<std::endl;
  225. }
  226. }
  227. private:
  228. // command, count
  229. std::map<u16, u16> m_packets;
  230. };
  231. class ClientScripting;
  232. struct GameUIFlags;
  233. class Client : public con::PeerHandler, public InventoryManager, public IGameDef
  234. {
  235. public:
  236. /*
  237. NOTE: Nothing is thread-safe here.
  238. */
  239. Client(
  240. IrrlichtDevice *device,
  241. const char *playername,
  242. const std::string &password,
  243. const std::string &address_name,
  244. MapDrawControl &control,
  245. IWritableTextureSource *tsrc,
  246. IWritableShaderSource *shsrc,
  247. IWritableItemDefManager *itemdef,
  248. IWritableNodeDefManager *nodedef,
  249. ISoundManager *sound,
  250. MtEventManager *event,
  251. bool ipv6,
  252. GameUIFlags *game_ui_flags
  253. );
  254. ~Client();
  255. DISABLE_CLASS_COPY(Client);
  256. void initMods();
  257. /*
  258. request all threads managed by client to be stopped
  259. */
  260. void Stop();
  261. bool isShutdown();
  262. /*
  263. The name of the local player should already be set when
  264. calling this, as it is sent in the initialization.
  265. */
  266. void connect(Address address, bool is_local_server);
  267. /*
  268. Stuff that references the environment is valid only as
  269. long as this is not called. (eg. Players)
  270. If this throws a PeerNotFoundException, the connection has
  271. timed out.
  272. */
  273. void step(float dtime);
  274. /*
  275. * Command Handlers
  276. */
  277. void handleCommand(NetworkPacket* pkt);
  278. void handleCommand_Null(NetworkPacket* pkt) {};
  279. void handleCommand_Deprecated(NetworkPacket* pkt);
  280. void handleCommand_Hello(NetworkPacket* pkt);
  281. void handleCommand_AuthAccept(NetworkPacket* pkt);
  282. void handleCommand_AcceptSudoMode(NetworkPacket* pkt);
  283. void handleCommand_DenySudoMode(NetworkPacket* pkt);
  284. void handleCommand_InitLegacy(NetworkPacket* pkt);
  285. void handleCommand_AccessDenied(NetworkPacket* pkt);
  286. void handleCommand_RemoveNode(NetworkPacket* pkt);
  287. void handleCommand_AddNode(NetworkPacket* pkt);
  288. void handleCommand_BlockData(NetworkPacket* pkt);
  289. void handleCommand_Inventory(NetworkPacket* pkt);
  290. void handleCommand_TimeOfDay(NetworkPacket* pkt);
  291. void handleCommand_ChatMessage(NetworkPacket* pkt);
  292. void handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt);
  293. void handleCommand_ActiveObjectMessages(NetworkPacket* pkt);
  294. void handleCommand_Movement(NetworkPacket* pkt);
  295. void handleCommand_HP(NetworkPacket* pkt);
  296. void handleCommand_Breath(NetworkPacket* pkt);
  297. void handleCommand_MovePlayer(NetworkPacket* pkt);
  298. void handleCommand_DeathScreen(NetworkPacket* pkt);
  299. void handleCommand_AnnounceMedia(NetworkPacket* pkt);
  300. void handleCommand_Media(NetworkPacket* pkt);
  301. void handleCommand_NodeDef(NetworkPacket* pkt);
  302. void handleCommand_ItemDef(NetworkPacket* pkt);
  303. void handleCommand_PlaySound(NetworkPacket* pkt);
  304. void handleCommand_StopSound(NetworkPacket* pkt);
  305. void handleCommand_FadeSound(NetworkPacket *pkt);
  306. void handleCommand_Privileges(NetworkPacket* pkt);
  307. void handleCommand_InventoryFormSpec(NetworkPacket* pkt);
  308. void handleCommand_DetachedInventory(NetworkPacket* pkt);
  309. void handleCommand_ShowFormSpec(NetworkPacket* pkt);
  310. void handleCommand_SpawnParticle(NetworkPacket* pkt);
  311. void handleCommand_AddParticleSpawner(NetworkPacket* pkt);
  312. void handleCommand_DeleteParticleSpawner(NetworkPacket* pkt);
  313. void handleCommand_HudAdd(NetworkPacket* pkt);
  314. void handleCommand_HudRemove(NetworkPacket* pkt);
  315. void handleCommand_HudChange(NetworkPacket* pkt);
  316. void handleCommand_HudSetFlags(NetworkPacket* pkt);
  317. void handleCommand_HudSetParam(NetworkPacket* pkt);
  318. void handleCommand_HudSetSky(NetworkPacket* pkt);
  319. void handleCommand_CloudParams(NetworkPacket* pkt);
  320. void handleCommand_OverrideDayNightRatio(NetworkPacket* pkt);
  321. void handleCommand_LocalPlayerAnimations(NetworkPacket* pkt);
  322. void handleCommand_EyeOffset(NetworkPacket* pkt);
  323. void handleCommand_UpdatePlayerList(NetworkPacket* pkt);
  324. void handleCommand_SrpBytesSandB(NetworkPacket* pkt);
  325. void ProcessData(NetworkPacket *pkt);
  326. void Send(NetworkPacket* pkt);
  327. void interact(u8 action, const PointedThing& pointed);
  328. void sendNodemetaFields(v3s16 p, const std::string &formname,
  329. const StringMap &fields);
  330. void sendInventoryFields(const std::string &formname,
  331. const StringMap &fields);
  332. void sendInventoryAction(InventoryAction *a);
  333. void sendChatMessage(const std::wstring &message);
  334. void clearOutChatQueue();
  335. void sendChangePassword(const std::string &oldpassword,
  336. const std::string &newpassword);
  337. void sendDamage(u8 damage);
  338. void sendBreath(u16 breath);
  339. void sendRespawn();
  340. void sendReady();
  341. ClientEnvironment& getEnv() { return m_env; }
  342. ITextureSource *tsrc() { return getTextureSource(); }
  343. ISoundManager *sound() { return getSoundManager(); }
  344. static const std::string &getBuiltinLuaPath();
  345. static const std::string &getClientModsLuaPath();
  346. virtual const std::vector<ModSpec> &getMods() const;
  347. virtual const ModSpec* getModSpec(const std::string &modname) const;
  348. // Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
  349. void removeNode(v3s16 p);
  350. MapNode getNode(v3s16 p, bool *is_valid_position);
  351. void addNode(v3s16 p, MapNode n, bool remove_metadata = true);
  352. void setPlayerControl(PlayerControl &control);
  353. void selectPlayerItem(u16 item);
  354. u16 getPlayerItem() const
  355. { return m_playeritem; }
  356. // Returns true if the inventory of the local player has been
  357. // updated from the server. If it is true, it is set to false.
  358. bool getLocalInventoryUpdated();
  359. // Copies the inventory of the local player to parameter
  360. void getLocalInventory(Inventory &dst);
  361. /* InventoryManager interface */
  362. Inventory* getInventory(const InventoryLocation &loc);
  363. void inventoryAction(InventoryAction *a);
  364. const std::list<std::string> &getConnectedPlayerNames()
  365. {
  366. return m_env.getPlayerNames();
  367. }
  368. float getAnimationTime();
  369. int getCrackLevel();
  370. v3s16 getCrackPos();
  371. void setCrack(int level, v3s16 pos);
  372. u16 getHP();
  373. bool checkPrivilege(const std::string &priv) const
  374. { return (m_privileges.count(priv) != 0); }
  375. const std::unordered_set<std::string> &getPrivilegeList() const
  376. { return m_privileges; }
  377. bool getChatMessage(std::wstring &message);
  378. void typeChatMessage(const std::wstring& message);
  379. u64 getMapSeed(){ return m_map_seed; }
  380. void addUpdateMeshTask(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
  381. // Including blocks at appropriate edges
  382. void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
  383. void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);
  384. void updateCameraOffset(v3s16 camera_offset)
  385. { m_mesh_update_thread.m_camera_offset = camera_offset; }
  386. bool hasClientEvents() const { return !m_client_event_queue.empty(); }
  387. // Get event from queue. If queue is empty, it triggers an assertion failure.
  388. ClientEvent getClientEvent();
  389. bool accessDenied() const { return m_access_denied; }
  390. bool reconnectRequested() const { return m_access_denied_reconnect; }
  391. void setFatalError(const std::string &reason)
  392. {
  393. m_access_denied = true;
  394. m_access_denied_reason = reason;
  395. }
  396. // Renaming accessDeniedReason to better name could be good as it's used to
  397. // disconnect client when CSM failed.
  398. const std::string &accessDeniedReason() const { return m_access_denied_reason; }
  399. bool itemdefReceived()
  400. { return m_itemdef_received; }
  401. bool nodedefReceived()
  402. { return m_nodedef_received; }
  403. bool mediaReceived()
  404. { return !m_media_downloader; }
  405. u8 getProtoVersion()
  406. { return m_proto_ver; }
  407. bool connectedToServer()
  408. { return m_con.Connected(); }
  409. float mediaReceiveProgress();
  410. void afterContentReceived(IrrlichtDevice *device);
  411. float getRTT();
  412. float getCurRate();
  413. Minimap* getMinimap() { return m_minimap; }
  414. void setCamera(Camera* camera) { m_camera = camera; }
  415. Camera* getCamera () { return m_camera; }
  416. bool shouldShowMinimap() const;
  417. // IGameDef interface
  418. virtual IItemDefManager* getItemDefManager();
  419. virtual INodeDefManager* getNodeDefManager();
  420. virtual ICraftDefManager* getCraftDefManager();
  421. ITextureSource* getTextureSource();
  422. virtual IShaderSource* getShaderSource();
  423. IShaderSource *shsrc() { return getShaderSource(); }
  424. scene::ISceneManager* getSceneManager();
  425. virtual u16 allocateUnknownNodeId(const std::string &name);
  426. virtual ISoundManager* getSoundManager();
  427. virtual MtEventManager* getEventManager();
  428. virtual ParticleManager* getParticleManager();
  429. bool checkLocalPrivilege(const std::string &priv)
  430. { return checkPrivilege(priv); }
  431. virtual scene::IAnimatedMesh* getMesh(const std::string &filename);
  432. virtual std::string getModStoragePath() const;
  433. virtual bool registerModStorage(ModMetadata *meta);
  434. virtual void unregisterModStorage(const std::string &name);
  435. // The following set of functions is used by ClientMediaDownloader
  436. // Insert a media file appropriately into the appropriate manager
  437. bool loadMedia(const std::string &data, const std::string &filename);
  438. // Send a request for conventional media transfer
  439. void request_media(const std::vector<std::string> &file_requests);
  440. LocalClientState getState() { return m_state; }
  441. void makeScreenshot(IrrlichtDevice *device);
  442. inline void pushToChatQueue(const std::wstring &input)
  443. {
  444. m_chat_queue.push(input);
  445. }
  446. ClientScripting *getScript() { return m_script; }
  447. const bool moddingEnabled() const { return m_modding_enabled; }
  448. inline void pushToEventQueue(const ClientEvent &event)
  449. {
  450. m_client_event_queue.push(event);
  451. }
  452. void showGameChat(const bool show = true);
  453. void showGameHud(const bool show = true);
  454. void showMinimap(const bool show = true);
  455. void showProfiler(const bool show = true);
  456. void showGameFog(const bool show = true);
  457. void showGameDebug(const bool show = true);
  458. IrrlichtDevice *getDevice() const { return m_device; }
  459. const Address getServerAddress()
  460. {
  461. return m_con.GetPeerAddress(PEER_ID_SERVER);
  462. }
  463. const std::string &getAddressName() const
  464. {
  465. return m_address_name;
  466. }
  467. private:
  468. // Virtual methods from con::PeerHandler
  469. void peerAdded(con::Peer *peer);
  470. void deletingPeer(con::Peer *peer, bool timeout);
  471. void initLocalMapSaving(const Address &address,
  472. const std::string &hostname,
  473. bool is_local_server);
  474. void ReceiveAll();
  475. void Receive();
  476. void sendPlayerPos();
  477. // Send the item number 'item' as player item to the server
  478. void sendPlayerItem(u16 item);
  479. void deleteAuthData();
  480. // helper method shared with clientpackethandler
  481. static AuthMechanism choseAuthMech(const u32 mechs);
  482. void sendLegacyInit(const char* playerName, const char* playerPassword);
  483. void sendInit(const std::string &playerName);
  484. void startAuth(AuthMechanism chosen_auth_mechanism);
  485. void sendDeletedBlocks(std::vector<v3s16> &blocks);
  486. void sendGotBlocks(v3s16 block);
  487. void sendRemovedSounds(std::vector<s32> &soundList);
  488. // Helper function
  489. inline std::string getPlayerName()
  490. { return m_env.getLocalPlayer()->getName(); }
  491. bool canSendChatMessage() const;
  492. float m_packetcounter_timer = 0.0f;
  493. float m_connection_reinit_timer = 0.1f;
  494. float m_avg_rtt_timer = 0.0f;
  495. float m_playerpos_send_timer = 0.0f;
  496. float m_ignore_damage_timer = 0.0f; // Used after server moves player
  497. IntervalLimiter m_map_timer_and_unload_interval;
  498. IWritableTextureSource *m_tsrc;
  499. IWritableShaderSource *m_shsrc;
  500. IWritableItemDefManager *m_itemdef;
  501. IWritableNodeDefManager *m_nodedef;
  502. ISoundManager *m_sound;
  503. MtEventManager *m_event;
  504. MeshUpdateThread m_mesh_update_thread;
  505. ClientEnvironment m_env;
  506. ParticleManager m_particle_manager;
  507. con::Connection m_con;
  508. std::string m_address_name;
  509. IrrlichtDevice *m_device;
  510. Camera *m_camera = nullptr;
  511. Minimap *m_minimap = nullptr;
  512. bool m_minimap_disabled_by_server = false;
  513. // Server serialization version
  514. u8 m_server_ser_ver;
  515. // Used version of the protocol with server
  516. // Values smaller than 25 only mean they are smaller than 25,
  517. // and aren't accurate. We simply just don't know, because
  518. // the server didn't send the version back then.
  519. // If 0, server init hasn't been received yet.
  520. u8 m_proto_ver = 0;
  521. u16 m_playeritem = 0;
  522. bool m_inventory_updated = false;
  523. Inventory *m_inventory_from_server = nullptr;
  524. float m_inventory_from_server_age = 0.0f;
  525. PacketCounter m_packetcounter;
  526. // Block mesh animation parameters
  527. float m_animation_time = 0.0f;
  528. int m_crack_level = -1;
  529. v3s16 m_crack_pos;
  530. // 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
  531. //s32 m_daynight_i;
  532. //u32 m_daynight_ratio;
  533. std::queue<std::wstring> m_chat_queue;
  534. std::queue<std::wstring> m_out_chat_queue;
  535. u32 m_last_chat_message_sent;
  536. float m_chat_message_allowance = 5.0f;
  537. // The authentication methods we can use to enter sudo mode (=change password)
  538. u32 m_sudo_auth_methods;
  539. // The seed returned by the server in TOCLIENT_INIT is stored here
  540. u64 m_map_seed = 0;
  541. // Auth data
  542. std::string m_playername;
  543. std::string m_password;
  544. // If set, this will be sent (and cleared) upon a TOCLIENT_ACCEPT_SUDO_MODE
  545. std::string m_new_password;
  546. // Usable by auth mechanisms.
  547. AuthMechanism m_chosen_auth_mech;
  548. void *m_auth_data = nullptr;
  549. bool m_access_denied = false;
  550. bool m_access_denied_reconnect = false;
  551. std::string m_access_denied_reason = "";
  552. std::queue<ClientEvent> m_client_event_queue;
  553. bool m_itemdef_received = false;
  554. bool m_nodedef_received = false;
  555. ClientMediaDownloader *m_media_downloader;
  556. // time_of_day speed approximation for old protocol
  557. bool m_time_of_day_set = false;
  558. float m_last_time_of_day_f = -1.0f;
  559. float m_time_of_day_update_timer = 0.0f;
  560. // An interval for generally sending object positions and stuff
  561. float m_recommended_send_interval = 0.1f;
  562. // Sounds
  563. float m_removed_sounds_check_timer = 0.0f;
  564. // Mapping from server sound ids to our sound ids
  565. std::unordered_map<s32, int> m_sounds_server_to_client;
  566. // And the other way!
  567. std::unordered_map<int, s32> m_sounds_client_to_server;
  568. // And relations to objects
  569. std::unordered_map<int, u16> m_sounds_to_objects;
  570. // Privileges
  571. std::unordered_set<std::string> m_privileges;
  572. // Detached inventories
  573. // key = name
  574. std::unordered_map<std::string, Inventory*> m_detached_inventories;
  575. // Storage for mesh data for creating multiple instances of the same mesh
  576. StringMap m_mesh_data;
  577. // own state
  578. LocalClientState m_state;
  579. // Used for saving server map to disk client-side
  580. MapDatabase *m_localdb = nullptr;
  581. IntervalLimiter m_localdb_save_interval;
  582. u16 m_cache_save_interval;
  583. ClientScripting *m_script = nullptr;
  584. bool m_modding_enabled;
  585. std::unordered_map<std::string, ModMetadata *> m_mod_storages;
  586. float m_mod_storage_save_timer = 10.0f;
  587. GameUIFlags *m_game_ui_flags;
  588. bool m_shutdown = false;
  589. };
  590. #endif // !CLIENT_HEADER