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