]> git.lizzy.rs Git - dragonfireclient.git/blob - src/server.h
Implement mod communication channels (#6351)
[dragonfireclient.git] / src / server.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #pragma once
21
22 #include "irr_v3d.h"
23 #include "map.h"
24 #include "hud.h"
25 #include "gamedef.h"
26 #include "serialization.h" // For SER_FMT_VER_INVALID
27 #include "mods.h"
28 #include "inventorymanager.h"
29 #include "subgame.h"
30 #include "tileanimation.h" // struct TileAnimationParams
31 #include "network/peerhandler.h"
32 #include "network/address.h"
33 #include "util/numeric.h"
34 #include "util/thread.h"
35 #include "util/basic_macros.h"
36 #include "serverenvironment.h"
37 #include "clientiface.h"
38 #include "chatmessage.h"
39 #include <string>
40 #include <list>
41 #include <map>
42 #include <vector>
43
44 class ChatEvent;
45 struct ChatEventChat;
46 struct ChatInterface;
47 class IWritableItemDefManager;
48 class IWritableNodeDefManager;
49 class IWritableCraftDefManager;
50 class BanManager;
51 class EventManager;
52 class Inventory;
53 class ModChannelMgr;
54 class RemotePlayer;
55 class PlayerSAO;
56 class IRollbackManager;
57 struct RollbackAction;
58 class EmergeManager;
59 class ServerScripting;
60 class ServerEnvironment;
61 struct SimpleSoundSpec;
62 class ServerThread;
63
64 enum ClientDeletionReason {
65         CDR_LEAVE,
66         CDR_TIMEOUT,
67         CDR_DENY
68 };
69
70 struct MediaInfo
71 {
72         std::string path;
73         std::string sha1_digest;
74
75         MediaInfo(const std::string &path_="",
76                   const std::string &sha1_digest_=""):
77                 path(path_),
78                 sha1_digest(sha1_digest_)
79         {
80         }
81 };
82
83 struct ServerSoundParams
84 {
85         enum Type {
86                 SSP_LOCAL,
87                 SSP_POSITIONAL,
88                 SSP_OBJECT
89         } type = SSP_LOCAL;
90         float gain = 1.0f;
91         float fade = 0.0f;
92         float pitch = 1.0f;
93         bool loop = false;
94         float max_hear_distance = 32 * BS;
95         v3f pos;
96         u16 object = 0;
97         std::string to_player = "";
98
99         v3f getPos(ServerEnvironment *env, bool *pos_exists) const;
100 };
101
102 struct ServerPlayingSound
103 {
104         ServerSoundParams params;
105         SimpleSoundSpec spec;
106         std::unordered_set<u16> clients; // peer ids
107 };
108
109 class Server : public con::PeerHandler, public MapEventReceiver,
110                 public InventoryManager, public IGameDef
111 {
112 public:
113         /*
114                 NOTE: Every public method should be thread-safe
115         */
116
117         Server(
118                 const std::string &path_world,
119                 const SubgameSpec &gamespec,
120                 bool simple_singleplayer_mode,
121                 bool ipv6,
122                 bool dedicated,
123                 ChatInterface *iface = nullptr
124         );
125         ~Server();
126         DISABLE_CLASS_COPY(Server);
127
128         void start(Address bind_addr);
129         void stop();
130         // This is mainly a way to pass the time to the server.
131         // Actual processing is done in an another thread.
132         void step(float dtime);
133         // This is run by ServerThread and does the actual processing
134         void AsyncRunStep(bool initial_step=false);
135         void Receive();
136         PlayerSAO* StageTwoClientInit(u16 peer_id);
137
138         /*
139          * Command Handlers
140          */
141
142         void handleCommand(NetworkPacket* pkt);
143
144         void handleCommand_Null(NetworkPacket* pkt) {};
145         void handleCommand_Deprecated(NetworkPacket* pkt);
146         void handleCommand_Init(NetworkPacket* pkt);
147         void handleCommand_Init2(NetworkPacket* pkt);
148         void handleCommand_ModChannelJoin(NetworkPacket *pkt);
149         void handleCommand_ModChannelLeave(NetworkPacket *pkt);
150         void handleCommand_ModChannelMsg(NetworkPacket *pkt);
151         void handleCommand_RequestMedia(NetworkPacket* pkt);
152         void handleCommand_ClientReady(NetworkPacket* pkt);
153         void handleCommand_GotBlocks(NetworkPacket* pkt);
154         void handleCommand_PlayerPos(NetworkPacket* pkt);
155         void handleCommand_DeletedBlocks(NetworkPacket* pkt);
156         void handleCommand_InventoryAction(NetworkPacket* pkt);
157         void handleCommand_ChatMessage(NetworkPacket* pkt);
158         void handleCommand_Damage(NetworkPacket* pkt);
159         void handleCommand_Password(NetworkPacket* pkt);
160         void handleCommand_PlayerItem(NetworkPacket* pkt);
161         void handleCommand_Respawn(NetworkPacket* pkt);
162         void handleCommand_Interact(NetworkPacket* pkt);
163         void handleCommand_RemovedSounds(NetworkPacket* pkt);
164         void handleCommand_NodeMetaFields(NetworkPacket* pkt);
165         void handleCommand_InventoryFields(NetworkPacket* pkt);
166         void handleCommand_FirstSrp(NetworkPacket* pkt);
167         void handleCommand_SrpBytesA(NetworkPacket* pkt);
168         void handleCommand_SrpBytesM(NetworkPacket* pkt);
169
170         void ProcessData(NetworkPacket *pkt);
171
172         void Send(NetworkPacket *pkt);
173         void Send(u16 peer_id, NetworkPacket *pkt);
174
175         // Helper for handleCommand_PlayerPos and handleCommand_Interact
176         void process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
177                 NetworkPacket *pkt);
178
179         // Both setter and getter need no envlock,
180         // can be called freely from threads
181         void setTimeOfDay(u32 time);
182
183         /*
184                 Shall be called with the environment locked.
185                 This is accessed by the map, which is inside the environment,
186                 so it shouldn't be a problem.
187         */
188         void onMapEditEvent(MapEditEvent *event);
189
190         /*
191                 Shall be called with the environment and the connection locked.
192         */
193         Inventory* getInventory(const InventoryLocation &loc);
194         void setInventoryModified(const InventoryLocation &loc, bool playerSend = true);
195
196         // Connection must be locked when called
197         std::wstring getStatusString();
198         inline double getUptime() const { return m_uptime.m_value; }
199
200         // read shutdown state
201         inline bool getShutdownRequested() const { return m_shutdown_requested; }
202
203         // request server to shutdown
204         void requestShutdown(const std::string &msg, bool reconnect, float delay = 0.0f);
205
206         // Returns -1 if failed, sound handle on success
207         // Envlock
208         s32 playSound(const SimpleSoundSpec &spec, const ServerSoundParams &params);
209         void stopSound(s32 handle);
210         void fadeSound(s32 handle, float step, float gain);
211
212         // Envlock
213         std::set<std::string> getPlayerEffectivePrivs(const std::string &name);
214         bool checkPriv(const std::string &name, const std::string &priv);
215         void reportPrivsModified(const std::string &name=""); // ""=all
216         void reportInventoryFormspecModified(const std::string &name);
217
218         void setIpBanned(const std::string &ip, const std::string &name);
219         void unsetIpBanned(const std::string &ip_or_name);
220         std::string getBanDescription(const std::string &ip_or_name);
221
222         void notifyPlayer(const char *name, const std::wstring &msg);
223         void notifyPlayers(const std::wstring &msg);
224         void spawnParticle(const std::string &playername,
225                 v3f pos, v3f velocity, v3f acceleration,
226                 float expirationtime, float size,
227                 bool collisiondetection, bool collision_removal,
228                 bool vertical, const std::string &texture,
229                 const struct TileAnimationParams &animation, u8 glow);
230
231         u32 addParticleSpawner(u16 amount, float spawntime,
232                 v3f minpos, v3f maxpos,
233                 v3f minvel, v3f maxvel,
234                 v3f minacc, v3f maxacc,
235                 float minexptime, float maxexptime,
236                 float minsize, float maxsize,
237                 bool collisiondetection, bool collision_removal,
238                 ServerActiveObject *attached,
239                 bool vertical, const std::string &texture,
240                 const std::string &playername, const struct TileAnimationParams &animation,
241                 u8 glow);
242
243         void deleteParticleSpawner(const std::string &playername, u32 id);
244
245         // Creates or resets inventory
246         Inventory* createDetachedInventory(const std::string &name, const std::string &player="");
247
248         // Envlock and conlock should be locked when using scriptapi
249         ServerScripting *getScriptIface(){ return m_script; }
250
251         // actions: time-reversed list
252         // Return value: success/failure
253         bool rollbackRevertActions(const std::list<RollbackAction> &actions,
254                         std::list<std::string> *log);
255
256         // IGameDef interface
257         // Under envlock
258         virtual IItemDefManager* getItemDefManager();
259         virtual INodeDefManager* getNodeDefManager();
260         virtual ICraftDefManager* getCraftDefManager();
261         virtual u16 allocateUnknownNodeId(const std::string &name);
262         virtual MtEventManager* getEventManager();
263         IRollbackManager *getRollbackManager() { return m_rollback; }
264         virtual EmergeManager *getEmergeManager() { return m_emerge; }
265
266         IWritableItemDefManager* getWritableItemDefManager();
267         IWritableNodeDefManager* getWritableNodeDefManager();
268         IWritableCraftDefManager* getWritableCraftDefManager();
269
270         virtual const std::vector<ModSpec> &getMods() const { return m_mods; }
271         virtual const ModSpec* getModSpec(const std::string &modname) const;
272         void getModNames(std::vector<std::string> &modlist);
273         std::string getBuiltinLuaPath();
274         virtual std::string getWorldPath() const { return m_path_world; }
275         virtual std::string getModStoragePath() const;
276
277         inline bool isSingleplayer()
278                         { return m_simple_singleplayer_mode; }
279
280         inline void setAsyncFatalError(const std::string &error)
281                         { m_async_fatal_error.set(error); }
282
283         bool showFormspec(const char *name, const std::string &formspec, const std::string &formname);
284         Map & getMap() { return m_env->getMap(); }
285         ServerEnvironment & getEnv() { return *m_env; }
286         v3f findSpawnPos();
287
288         u32 hudAdd(RemotePlayer *player, HudElement *element);
289         bool hudRemove(RemotePlayer *player, u32 id);
290         bool hudChange(RemotePlayer *player, u32 id, HudElementStat stat, void *value);
291         bool hudSetFlags(RemotePlayer *player, u32 flags, u32 mask);
292         bool hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount);
293         s32 hudGetHotbarItemcount(RemotePlayer *player) const;
294         void hudSetHotbarImage(RemotePlayer *player, std::string name);
295         std::string hudGetHotbarImage(RemotePlayer *player);
296         void hudSetHotbarSelectedImage(RemotePlayer *player, std::string name);
297         const std::string &hudGetHotbarSelectedImage(RemotePlayer *player) const;
298
299         Address getPeerAddress(u16 peer_id);
300
301         bool setLocalPlayerAnimations(RemotePlayer *player, v2s32 animation_frames[4],
302                         f32 frame_speed);
303         bool setPlayerEyeOffset(RemotePlayer *player, v3f first, v3f third);
304
305         bool setSky(RemotePlayer *player, const video::SColor &bgcolor,
306                         const std::string &type, const std::vector<std::string> &params,
307                         bool &clouds);
308         bool setClouds(RemotePlayer *player, float density,
309                         const video::SColor &color_bright,
310                         const video::SColor &color_ambient,
311                         float height,
312                         float thickness,
313                         const v2f &speed);
314
315         bool overrideDayNightRatio(RemotePlayer *player, bool do_override, float brightness);
316
317         /* con::PeerHandler implementation. */
318         void peerAdded(con::Peer *peer);
319         void deletingPeer(con::Peer *peer, bool timeout);
320
321         void DenySudoAccess(u16 peer_id);
322         void DenyAccessVerCompliant(u16 peer_id, u16 proto_ver, AccessDeniedCode reason,
323                 const std::string &str_reason = "", bool reconnect = false);
324         void DenyAccess(u16 peer_id, AccessDeniedCode reason, const std::string &custom_reason="");
325         void acceptAuth(u16 peer_id, bool forSudoMode);
326         void DenyAccess_Legacy(u16 peer_id, const std::wstring &reason);
327         void DisconnectPeer(u16 peer_id);
328         bool getClientConInfo(u16 peer_id, con::rtt_stat_type type, float* retval);
329         bool getClientInfo(u16 peer_id,ClientState* state, u32* uptime,
330                         u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch,
331                         std::string* vers_string);
332
333         void printToConsoleOnly(const std::string &text);
334
335         void SendPlayerHPOrDie(PlayerSAO *player);
336         void SendPlayerBreath(PlayerSAO *sao);
337         void SendInventory(PlayerSAO* playerSAO);
338         void SendMovePlayer(u16 peer_id);
339
340         virtual bool registerModStorage(ModMetadata *storage);
341         virtual void unregisterModStorage(const std::string &name);
342
343         bool joinModChannel(const std::string &channel);
344         bool leaveModChannel(const std::string &channel);
345         bool sendModChannelMessage(const std::string &channel, const std::string &message);
346         ModChannel *getModChannel(const std::string &channel);
347
348         // Bind address
349         Address m_bind_addr;
350
351         // Environment mutex (envlock)
352         std::mutex m_env_mutex;
353
354 private:
355
356         friend class EmergeThread;
357         friend class RemoteClient;
358
359         void SendMovement(u16 peer_id);
360         void SendHP(u16 peer_id, u16 hp);
361         void SendBreath(u16 peer_id, u16 breath);
362         void SendAccessDenied(u16 peer_id, AccessDeniedCode reason,
363                 const std::string &custom_reason, bool reconnect = false);
364         void SendAccessDenied_Legacy(u16 peer_id, const std::wstring &reason);
365         void SendDeathscreen(u16 peer_id,bool set_camera_point_target, v3f camera_point_target);
366         void SendItemDef(u16 peer_id,IItemDefManager *itemdef, u16 protocol_version);
367         void SendNodeDef(u16 peer_id,INodeDefManager *nodedef, u16 protocol_version);
368
369         /* mark blocks not sent for all clients */
370         void SetBlocksNotSent(std::map<v3s16, MapBlock *>& block);
371
372
373         void SendChatMessage(u16 peer_id, const ChatMessage &message);
374         void SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed);
375         void SendPlayerHP(u16 peer_id);
376
377         void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
378         void SendEyeOffset(u16 peer_id, v3f first, v3f third);
379         void SendPlayerPrivileges(u16 peer_id);
380         void SendPlayerInventoryFormspec(u16 peer_id);
381         void SendShowFormspecMessage(u16 peer_id, const std::string &formspec, const std::string &formname);
382         void SendHUDAdd(u16 peer_id, u32 id, HudElement *form);
383         void SendHUDRemove(u16 peer_id, u32 id);
384         void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value);
385         void SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask);
386         void SendHUDSetParam(u16 peer_id, u16 param, const std::string &value);
387         void SendSetSky(u16 peer_id, const video::SColor &bgcolor,
388                         const std::string &type, const std::vector<std::string> &params,
389                         bool &clouds);
390         void SendCloudParams(u16 peer_id, float density,
391                         const video::SColor &color_bright,
392                         const video::SColor &color_ambient,
393                         float height,
394                         float thickness,
395                         const v2f &speed);
396         void SendOverrideDayNightRatio(u16 peer_id, bool do_override, float ratio);
397         void broadcastModChannelMessage(const std::string &channel,
398                         const std::string &message, u16 from_peer);
399
400         /*
401                 Send a node removal/addition event to all clients except ignore_id.
402                 Additionally, if far_players!=NULL, players further away than
403                 far_d_nodes are ignored and their peer_ids are added to far_players
404         */
405         // Envlock and conlock should be locked when calling these
406         void sendRemoveNode(v3s16 p, u16 ignore_id=0,
407                         std::vector<u16> *far_players=NULL, float far_d_nodes=100);
408         void sendAddNode(v3s16 p, MapNode n, u16 ignore_id=0,
409                         std::vector<u16> *far_players=NULL, float far_d_nodes=100,
410                         bool remove_metadata=true);
411         void setBlockNotSent(v3s16 p);
412
413         // Environment and Connection must be locked when called
414         void SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto_version);
415
416         // Sends blocks to clients (locks env and con on its own)
417         void SendBlocks(float dtime);
418
419         void fillMediaCache();
420         void sendMediaAnnouncement(u16 peer_id, const std::string &lang_code);
421         void sendRequestedMedia(u16 peer_id,
422                         const std::vector<std::string> &tosend);
423
424         void sendDetachedInventory(const std::string &name, u16 peer_id);
425         void sendDetachedInventories(u16 peer_id);
426
427         // Adds a ParticleSpawner on peer with peer_id (PEER_ID_INEXISTENT == all)
428         void SendAddParticleSpawner(u16 peer_id, u16 protocol_version,
429                 u16 amount, float spawntime,
430                 v3f minpos, v3f maxpos,
431                 v3f minvel, v3f maxvel,
432                 v3f minacc, v3f maxacc,
433                 float minexptime, float maxexptime,
434                 float minsize, float maxsize,
435                 bool collisiondetection, bool collision_removal,
436                 u16 attached_id,
437                 bool vertical, const std::string &texture, u32 id,
438                 const struct TileAnimationParams &animation, u8 glow);
439
440         void SendDeleteParticleSpawner(u16 peer_id, u32 id);
441
442         // Spawns particle on peer with peer_id (PEER_ID_INEXISTENT == all)
443         void SendSpawnParticle(u16 peer_id, u16 protocol_version,
444                 v3f pos, v3f velocity, v3f acceleration,
445                 float expirationtime, float size,
446                 bool collisiondetection, bool collision_removal,
447                 bool vertical, const std::string &texture,
448                 const struct TileAnimationParams &animation, u8 glow);
449
450         u32 SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas);
451         void SendActiveObjectMessages(u16 peer_id, const std::string &datas, bool reliable = true);
452         void SendCSMFlavourLimits(u16 peer_id);
453
454         /*
455                 Something random
456         */
457
458         void DiePlayer(u16 peer_id);
459         void RespawnPlayer(u16 peer_id);
460         void DeleteClient(u16 peer_id, ClientDeletionReason reason);
461         void UpdateCrafting(RemotePlayer *player);
462
463         void handleChatInterfaceEvent(ChatEvent *evt);
464
465         // This returns the answer to the sender of wmessage, or "" if there is none
466         std::wstring handleChat(const std::string &name, const std::wstring &wname,
467                 std::wstring wmessage_input,
468                 bool check_shout_priv = false,
469                 RemotePlayer *player = NULL);
470         void handleAdminChat(const ChatEventChat *evt);
471
472         // When called, connection mutex should be locked
473         RemoteClient* getClient(u16 peer_id,ClientState state_min=CS_Active);
474         RemoteClient* getClientNoEx(u16 peer_id,ClientState state_min=CS_Active);
475
476         // When called, environment mutex should be locked
477         std::string getPlayerName(u16 peer_id);
478         PlayerSAO* getPlayerSAO(u16 peer_id);
479
480         /*
481                 Get a player from memory or creates one.
482                 If player is already connected, return NULL
483                 Does not verify/modify auth info and password.
484
485                 Call with env and con locked.
486         */
487         PlayerSAO *emergePlayer(const char *name, u16 peer_id, u16 proto_version);
488
489         void handlePeerChanges();
490
491         /*
492                 Variables
493         */
494
495         // World directory
496         std::string m_path_world;
497         // Subgame specification
498         SubgameSpec m_gamespec;
499         // If true, do not allow multiple players and hide some multiplayer
500         // functionality
501         bool m_simple_singleplayer_mode;
502         u16 m_max_chatmessage_length;
503         // For "dedicated" server list flag
504         bool m_dedicated;
505
506         // Thread can set; step() will throw as ServerError
507         MutexedVariable<std::string> m_async_fatal_error;
508
509         // Some timers
510         float m_liquid_transform_timer = 0.0f;
511         float m_liquid_transform_every = 1.0f;
512         float m_masterserver_timer = 0.0f;
513         float m_emergethread_trigger_timer = 0.0f;
514         float m_savemap_timer = 0.0f;
515         IntervalLimiter m_map_timer_and_unload_interval;
516
517         // Environment
518         ServerEnvironment *m_env = nullptr;
519
520         // server connection
521         std::shared_ptr<con::Connection> m_con;
522
523         // Ban checking
524         BanManager *m_banmanager = nullptr;
525
526         // Rollback manager (behind m_env_mutex)
527         IRollbackManager *m_rollback = nullptr;
528         bool m_enable_rollback_recording = false; // Updated once in a while
529
530         // Emerge manager
531         EmergeManager *m_emerge = nullptr;
532
533         // Scripting
534         // Envlock and conlock should be locked when using Lua
535         ServerScripting *m_script = nullptr;
536
537         // Item definition manager
538         IWritableItemDefManager *m_itemdef;
539
540         // Node definition manager
541         IWritableNodeDefManager *m_nodedef;
542
543         // Craft definition manager
544         IWritableCraftDefManager *m_craftdef;
545
546         // Event manager
547         EventManager *m_event;
548
549         // Mods
550         std::vector<ModSpec> m_mods;
551
552         /*
553                 Threads
554         */
555
556         // A buffer for time steps
557         // step() increments and AsyncRunStep() run by m_thread reads it.
558         float m_step_dtime = 0.0f;
559         std::mutex m_step_dtime_mutex;
560
561         // current server step lag counter
562         float m_lag;
563
564         // The server mainly operates in this thread
565         ServerThread *m_thread = nullptr;
566
567         /*
568                 Time related stuff
569         */
570
571         // Timer for sending time of day over network
572         float m_time_of_day_send_timer = 0.0f;
573         // Uptime of server in seconds
574         MutexedVariable<double> m_uptime;
575         /*
576          Client interface
577          */
578         ClientInterface m_clients;
579
580         /*
581                 Peer change queue.
582                 Queues stuff from peerAdded() and deletingPeer() to
583                 handlePeerChanges()
584         */
585         std::queue<con::PeerChange> m_peer_change_queue;
586
587         /*
588                 Random stuff
589         */
590
591         bool m_shutdown_requested = false;
592         std::string m_shutdown_msg;
593         bool m_shutdown_ask_reconnect = false;
594         float m_shutdown_timer = 0.0f;
595
596         ChatInterface *m_admin_chat;
597         std::string m_admin_nick;
598
599         /*
600                 Map edit event queue. Automatically receives all map edits.
601                 The constructor of this class registers us to receive them through
602                 onMapEditEvent
603
604                 NOTE: Should these be moved to actually be members of
605                 ServerEnvironment?
606         */
607
608         /*
609                 Queue of map edits from the environment for sending to the clients
610                 This is behind m_env_mutex
611         */
612         std::queue<MapEditEvent*> m_unsent_map_edit_queue;
613         /*
614                 Set to true when the server itself is modifying the map and does
615                 all sending of information by itself.
616                 This is behind m_env_mutex
617         */
618         bool m_ignore_map_edit_events = false;
619         /*
620                 If a non-empty area, map edit events contained within are left
621                 unsent. Done at map generation time to speed up editing of the
622                 generated area, as it will be sent anyway.
623                 This is behind m_env_mutex
624         */
625         VoxelArea m_ignore_map_edit_events_area;
626         /*
627                 If set to !=0, the incoming MapEditEvents are modified to have
628                 this peed id as the disabled recipient
629                 This is behind m_env_mutex
630         */
631         u16 m_ignore_map_edit_events_peer_id = 0;
632
633         // media files known to server
634         std::unordered_map<std::string, MediaInfo> m_media;
635
636         /*
637                 Sounds
638         */
639         std::unordered_map<s32, ServerPlayingSound> m_playing_sounds;
640         s32 m_next_sound_id = 0;
641
642         /*
643                 Detached inventories (behind m_env_mutex)
644         */
645         // key = name
646         std::map<std::string, Inventory*> m_detached_inventories;
647         // value = "" (visible to all players) or player name
648         std::map<std::string, std::string> m_detached_inventories_player;
649
650         std::unordered_map<std::string, ModMetadata *> m_mod_storages;
651         float m_mod_storage_save_timer = 10.0f;
652
653         // CSM flavour limits byteflag
654         u64 m_csm_flavour_limits = CSMFlavourLimit::CSM_FL_NONE;
655         u32 m_csm_noderange_limit = 8;
656
657         // ModChannel manager
658         std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
659 };
660
661 /*
662         Runs a simple dedicated server loop.
663
664         Shuts down when kill is set to true.
665 */
666 void dedicated_server_loop(Server &server, bool &kill);