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