Use GenericCAO in place of LuaEntityCAO and PlayerCAO
[oweals/minetest.git] / src / server.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 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 General Public License as published by
7 the Free Software Foundation; either version 2 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 General Public License for more details.
14
15 You should have received a copy of the GNU 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 "connection.h"
24 #include "environment.h"
25 #include "common_irrlicht.h"
26 #include <string>
27 #include "porting.h"
28 #include "map.h"
29 #include "inventory.h"
30 #include "auth.h"
31 #include "ban.h"
32 #include "gamedef.h"
33 #include "serialization.h" // For SER_FMT_VER_INVALID
34 #include "mods.h"
35 #include "inventorymanager.h"
36 #include "subgame.h"
37 #include "sound.h"
38 struct LuaState;
39 typedef struct lua_State lua_State;
40 class IWritableItemDefManager;
41 class IWritableNodeDefManager;
42 class IWritableCraftDefManager;
43 class EventManager;
44 class PlayerSAO;
45
46 class ServerError : public std::exception
47 {
48 public:
49         ServerError(const std::string &s)
50         {
51                 m_s = "ServerError: ";
52                 m_s += s;
53         }
54         virtual ~ServerError() throw()
55         {}
56         virtual const char * what() const throw()
57         {
58                 return m_s.c_str();
59         }
60         std::string m_s;
61 };
62
63 /*
64         Some random functions
65 */
66 v3f findSpawnPos(ServerMap &map);
67
68 /*
69         A structure containing the data needed for queueing the fetching
70         of blocks.
71 */
72 struct QueuedBlockEmerge
73 {
74         v3s16 pos;
75         // key = peer_id, value = flags
76         core::map<u16, u8> peer_ids;
77 };
78
79 /*
80         This is a thread-safe class.
81 */
82 class BlockEmergeQueue
83 {
84 public:
85         BlockEmergeQueue()
86         {
87                 m_mutex.Init();
88         }
89
90         ~BlockEmergeQueue()
91         {
92                 JMutexAutoLock lock(m_mutex);
93
94                 core::list<QueuedBlockEmerge*>::Iterator i;
95                 for(i=m_queue.begin(); i!=m_queue.end(); i++)
96                 {
97                         QueuedBlockEmerge *q = *i;
98                         delete q;
99                 }
100         }
101         
102         /*
103                 peer_id=0 adds with nobody to send to
104         */
105         void addBlock(u16 peer_id, v3s16 pos, u8 flags)
106         {
107                 DSTACK(__FUNCTION_NAME);
108         
109                 JMutexAutoLock lock(m_mutex);
110
111                 if(peer_id != 0)
112                 {
113                         /*
114                                 Find if block is already in queue.
115                                 If it is, update the peer to it and quit.
116                         */
117                         core::list<QueuedBlockEmerge*>::Iterator i;
118                         for(i=m_queue.begin(); i!=m_queue.end(); i++)
119                         {
120                                 QueuedBlockEmerge *q = *i;
121                                 if(q->pos == pos)
122                                 {
123                                         q->peer_ids[peer_id] = flags;
124                                         return;
125                                 }
126                         }
127                 }
128                 
129                 /*
130                         Add the block
131                 */
132                 QueuedBlockEmerge *q = new QueuedBlockEmerge;
133                 q->pos = pos;
134                 if(peer_id != 0)
135                         q->peer_ids[peer_id] = flags;
136                 m_queue.push_back(q);
137         }
138
139         // Returned pointer must be deleted
140         // Returns NULL if queue is empty
141         QueuedBlockEmerge * pop()
142         {
143                 JMutexAutoLock lock(m_mutex);
144
145                 core::list<QueuedBlockEmerge*>::Iterator i = m_queue.begin();
146                 if(i == m_queue.end())
147                         return NULL;
148                 QueuedBlockEmerge *q = *i;
149                 m_queue.erase(i);
150                 return q;
151         }
152
153         u32 size()
154         {
155                 JMutexAutoLock lock(m_mutex);
156                 return m_queue.size();
157         }
158         
159         u32 peerItemCount(u16 peer_id)
160         {
161                 JMutexAutoLock lock(m_mutex);
162
163                 u32 count = 0;
164
165                 core::list<QueuedBlockEmerge*>::Iterator i;
166                 for(i=m_queue.begin(); i!=m_queue.end(); i++)
167                 {
168                         QueuedBlockEmerge *q = *i;
169                         if(q->peer_ids.find(peer_id) != NULL)
170                                 count++;
171                 }
172
173                 return count;
174         }
175
176 private:
177         core::list<QueuedBlockEmerge*> m_queue;
178         JMutex m_mutex;
179 };
180
181 class Server;
182
183 class ServerThread : public SimpleThread
184 {
185         Server *m_server;
186
187 public:
188
189         ServerThread(Server *server):
190                 SimpleThread(),
191                 m_server(server)
192         {
193         }
194
195         void * Thread();
196 };
197
198 class EmergeThread : public SimpleThread
199 {
200         Server *m_server;
201
202 public:
203
204         EmergeThread(Server *server):
205                 SimpleThread(),
206                 m_server(server)
207         {
208         }
209
210         void * Thread();
211
212         void trigger()
213         {
214                 setRun(true);
215                 if(IsRunning() == false)
216                 {
217                         Start();
218                 }
219         }
220 };
221
222 struct PlayerInfo
223 {
224         u16 id;
225         char name[PLAYERNAME_SIZE];
226         v3f position;
227         Address address;
228         float avg_rtt;
229
230         PlayerInfo();
231         void PrintLine(std::ostream *s);
232 };
233
234 /*
235         Used for queueing and sorting block transfers in containers
236         
237         Lower priority number means higher priority.
238 */
239 struct PrioritySortedBlockTransfer
240 {
241         PrioritySortedBlockTransfer(float a_priority, v3s16 a_pos, u16 a_peer_id)
242         {
243                 priority = a_priority;
244                 pos = a_pos;
245                 peer_id = a_peer_id;
246         }
247         bool operator < (PrioritySortedBlockTransfer &other)
248         {
249                 return priority < other.priority;
250         }
251         float priority;
252         v3s16 pos;
253         u16 peer_id;
254 };
255
256 struct MediaRequest
257 {
258         std::string name;
259
260         MediaRequest(const std::string &name_=""):
261                 name(name_)
262         {}
263 };
264
265 struct MediaInfo
266 {
267         std::string path;
268         std::string sha1_digest;
269
270         MediaInfo(const std::string path_="",
271                         const std::string sha1_digest_=""):
272                 path(path_),
273                 sha1_digest(sha1_digest_)
274         {
275         }
276 };
277
278 struct ServerSoundParams
279 {
280         float gain;
281         std::string to_player;
282         enum Type{
283                 SSP_LOCAL=0,
284                 SSP_POSITIONAL=1,
285                 SSP_OBJECT=2
286         } type;
287         v3f pos;
288         u16 object;
289         float max_hear_distance;
290         bool loop;
291
292         ServerSoundParams():
293                 gain(1.0),
294                 to_player(""),
295                 type(SSP_LOCAL),
296                 pos(0,0,0),
297                 object(0),
298                 max_hear_distance(32*BS),
299                 loop(false)
300         {}
301         
302         v3f getPos(ServerEnvironment *env, bool *pos_exists) const;
303 };
304
305 struct ServerPlayingSound
306 {
307         ServerSoundParams params;
308         std::set<u16> clients; // peer ids
309 };
310
311 class RemoteClient
312 {
313 public:
314         // peer_id=0 means this client has no associated peer
315         // NOTE: If client is made allowed to exist while peer doesn't,
316         //       this has to be set to 0 when there is no peer.
317         //       Also, the client must be moved to some other container.
318         u16 peer_id;
319         // The serialization version to use with the client
320         u8 serialization_version;
321         //
322         u16 net_proto_version;
323         // Version is stored in here after INIT before INIT2
324         u8 pending_serialization_version;
325
326         bool definitions_sent;
327
328         RemoteClient():
329                 m_time_from_building(9999),
330                 m_excess_gotblocks(0)
331         {
332                 peer_id = 0;
333                 serialization_version = SER_FMT_VER_INVALID;
334                 net_proto_version = 0;
335                 pending_serialization_version = SER_FMT_VER_INVALID;
336                 definitions_sent = false;
337                 m_nearest_unsent_d = 0;
338                 m_nearest_unsent_reset_timer = 0.0;
339                 m_nothing_to_send_counter = 0;
340                 m_nothing_to_send_pause_timer = 0;
341         }
342         ~RemoteClient()
343         {
344         }
345         
346         /*
347                 Finds block that should be sent next to the client.
348                 Environment should be locked when this is called.
349                 dtime is used for resetting send radius at slow interval
350         */
351         void GetNextBlocks(Server *server, float dtime,
352                         core::array<PrioritySortedBlockTransfer> &dest);
353
354         void GotBlock(v3s16 p);
355
356         void SentBlock(v3s16 p);
357
358         void SetBlockNotSent(v3s16 p);
359         void SetBlocksNotSent(core::map<v3s16, MapBlock*> &blocks);
360
361         s32 SendingCount()
362         {
363                 return m_blocks_sending.size();
364         }
365         
366         // Increments timeouts and removes timed-out blocks from list
367         // NOTE: This doesn't fix the server-not-sending-block bug
368         //       because it is related to emerging, not sending.
369         //void RunSendingTimeouts(float dtime, float timeout);
370
371         void PrintInfo(std::ostream &o)
372         {
373                 o<<"RemoteClient "<<peer_id<<": "
374                                 <<"m_blocks_sent.size()="<<m_blocks_sent.size()
375                                 <<", m_blocks_sending.size()="<<m_blocks_sending.size()
376                                 <<", m_nearest_unsent_d="<<m_nearest_unsent_d
377                                 <<", m_excess_gotblocks="<<m_excess_gotblocks
378                                 <<std::endl;
379                 m_excess_gotblocks = 0;
380         }
381
382         // Time from last placing or removing blocks
383         float m_time_from_building;
384         
385         /*JMutex m_dig_mutex;
386         float m_dig_time_remaining;
387         // -1 = not digging
388         s16 m_dig_tool_item;
389         v3s16 m_dig_position;*/
390         
391         /*
392                 List of active objects that the client knows of.
393                 Value is dummy.
394         */
395         core::map<u16, bool> m_known_objects;
396
397 private:
398         /*
399                 Blocks that have been sent to client.
400                 - These don't have to be sent again.
401                 - A block is cleared from here when client says it has
402                   deleted it from it's memory
403                 
404                 Key is position, value is dummy.
405                 No MapBlock* is stored here because the blocks can get deleted.
406         */
407         core::map<v3s16, bool> m_blocks_sent;
408         s16 m_nearest_unsent_d;
409         v3s16 m_last_center;
410         float m_nearest_unsent_reset_timer;
411         
412         /*
413                 Blocks that are currently on the line.
414                 This is used for throttling the sending of blocks.
415                 - The size of this list is limited to some value
416                 Block is added when it is sent with BLOCKDATA.
417                 Block is removed when GOTBLOCKS is received.
418                 Value is time from sending. (not used at the moment)
419         */
420         core::map<v3s16, float> m_blocks_sending;
421
422         /*
423                 Count of excess GotBlocks().
424                 There is an excess amount because the client sometimes
425                 gets a block so late that the server sends it again,
426                 and the client then sends two GOTBLOCKs.
427                 This is resetted by PrintInfo()
428         */
429         u32 m_excess_gotblocks;
430         
431         // CPU usage optimization
432         u32 m_nothing_to_send_counter;
433         float m_nothing_to_send_pause_timer;
434 };
435
436 class Server : public con::PeerHandler, public MapEventReceiver,
437                 public InventoryManager, public IGameDef,
438                 public IBackgroundBlockEmerger
439 {
440 public:
441         /*
442                 NOTE: Every public method should be thread-safe
443         */
444         
445         Server(
446                 const std::string &path_world,
447                 const std::string &path_config,
448                 const SubgameSpec &gamespec,
449                 bool simple_singleplayer_mode
450         );
451         ~Server();
452         void start(unsigned short port);
453         void stop();
454         // This is mainly a way to pass the time to the server.
455         // Actual processing is done in an another thread.
456         void step(float dtime);
457         // This is run by ServerThread and does the actual processing
458         void AsyncRunStep();
459         void Receive();
460         void ProcessData(u8 *data, u32 datasize, u16 peer_id);
461
462         core::list<PlayerInfo> getPlayerInfo();
463
464         // Environment must be locked when called
465         void setTimeOfDay(u32 time)
466         {
467                 m_env->setTimeOfDay(time);
468                 m_time_of_day_send_timer = 0;
469         }
470
471         bool getShutdownRequested()
472         {
473                 return m_shutdown_requested;
474         }
475         
476         /*
477                 Shall be called with the environment locked.
478                 This is accessed by the map, which is inside the environment,
479                 so it shouldn't be a problem.
480         */
481         void onMapEditEvent(MapEditEvent *event);
482
483         /*
484                 Shall be called with the environment and the connection locked.
485         */
486         Inventory* getInventory(const InventoryLocation &loc);
487         std::string getInventoryOwner(const InventoryLocation &loc);
488         void setInventoryModified(const InventoryLocation &loc);
489
490         // Connection must be locked when called
491         std::wstring getStatusString();
492
493         void requestShutdown(void)
494         {
495                 m_shutdown_requested = true;
496         }
497
498         // Returns -1 if failed, sound handle on success
499         // Envlock + conlock
500         s32 playSound(const SimpleSoundSpec &spec, const ServerSoundParams &params);
501         void stopSound(s32 handle);
502         
503         // Thread-safe
504         u64 getPlayerAuthPrivs(const std::string &name);
505         void setPlayerAuthPrivs(const std::string &name, u64 privs);
506         u64 getPlayerEffectivePrivs(const std::string &name);
507
508         // Changes a player's password, password must be given as plaintext
509         // If the player doesn't exist, a new entry is added to the auth manager
510         void setPlayerPassword(const std::string &name, const std::wstring &password);
511         
512         // Saves g_settings to configpath given at initialization
513         void saveConfig();
514
515         void setIpBanned(const std::string &ip, const std::string &name)
516         {
517                 m_banmanager.add(ip, name);
518                 return;
519         }
520
521         void unsetIpBanned(const std::string &ip_or_name)
522         {
523                 m_banmanager.remove(ip_or_name);
524                 return;
525         }
526
527         std::string getBanDescription(const std::string &ip_or_name)
528         {
529                 return m_banmanager.getBanDescription(ip_or_name);
530         }
531
532         Address getPeerAddress(u16 peer_id)
533         {
534                 return m_con.GetPeerAddress(peer_id);
535         }
536         
537         // Envlock and conlock should be locked when calling this
538         void notifyPlayer(const char *name, const std::wstring msg);
539         void notifyPlayers(const std::wstring msg);
540
541         void queueBlockEmerge(v3s16 blockpos, bool allow_generate);
542         
543         // Envlock and conlock should be locked when using Lua
544         lua_State *getLua(){ return m_lua; }
545         
546         // IGameDef interface
547         // Under envlock
548         virtual IItemDefManager* getItemDefManager();
549         virtual INodeDefManager* getNodeDefManager();
550         virtual ICraftDefManager* getCraftDefManager();
551         virtual ITextureSource* getTextureSource();
552         virtual u16 allocateUnknownNodeId(const std::string &name);
553         virtual ISoundManager* getSoundManager();
554         virtual MtEventManager* getEventManager();
555         
556         IWritableItemDefManager* getWritableItemDefManager();
557         IWritableNodeDefManager* getWritableNodeDefManager();
558         IWritableCraftDefManager* getWritableCraftDefManager();
559
560         const ModSpec* getModSpec(const std::string &modname);
561         
562         std::string getWorldPath(){ return m_path_world; }
563
564         bool isSingleplayer(){ return m_simple_singleplayer_mode; }
565
566         void setAsyncFatalError(const std::string &error)
567         {
568                 m_async_fatal_error.set(error);
569         }
570
571 private:
572
573         // con::PeerHandler implementation.
574         // These queue stuff to be processed by handlePeerChanges().
575         // As of now, these create and remove clients and players.
576         void peerAdded(con::Peer *peer);
577         void deletingPeer(con::Peer *peer, bool timeout);
578         
579         /*
580                 Static send methods
581         */
582         
583         static void SendHP(con::Connection &con, u16 peer_id, u8 hp);
584         static void SendAccessDenied(con::Connection &con, u16 peer_id,
585                         const std::wstring &reason);
586         static void SendDeathscreen(con::Connection &con, u16 peer_id,
587                         bool set_camera_point_target, v3f camera_point_target);
588         static void SendItemDef(con::Connection &con, u16 peer_id,
589                         IItemDefManager *itemdef);
590         static void SendNodeDef(con::Connection &con, u16 peer_id,
591                         INodeDefManager *nodedef);
592         
593         /*
594                 Non-static send methods.
595                 Conlock should be always used.
596                 Envlock usage is documented badly but it's easy to figure out
597                 which ones access the environment.
598         */
599
600         // Envlock and conlock should be locked when calling these
601         void SendMovePlayer(u16 peer_id);
602         void SendInventory(u16 peer_id);
603         void SendChatMessage(u16 peer_id, const std::wstring &message);
604         void BroadcastChatMessage(const std::wstring &message);
605         void SendPlayerHP(u16 peer_id);
606         /*
607                 Send a node removal/addition event to all clients except ignore_id.
608                 Additionally, if far_players!=NULL, players further away than
609                 far_d_nodes are ignored and their peer_ids are added to far_players
610         */
611         // Envlock and conlock should be locked when calling these
612         void sendRemoveNode(v3s16 p, u16 ignore_id=0,
613                         core::list<u16> *far_players=NULL, float far_d_nodes=100);
614         void sendAddNode(v3s16 p, MapNode n, u16 ignore_id=0,
615                         core::list<u16> *far_players=NULL, float far_d_nodes=100);
616         void setBlockNotSent(v3s16 p);
617         
618         // Environment and Connection must be locked when called
619         void SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver);
620         
621         // Sends blocks to clients (locks env and con on its own)
622         void SendBlocks(float dtime);
623         
624         void fillMediaCache();
625         void sendMediaAnnouncement(u16 peer_id);
626         void sendRequestedMedia(u16 peer_id,
627                         const core::list<MediaRequest> &tosend);
628
629         /*
630                 Something random
631         */
632         
633         void DiePlayer(u16 peer_id);
634         void RespawnPlayer(u16 peer_id);
635         
636         void UpdateCrafting(u16 peer_id);
637         
638         // When called, connection mutex should be locked
639         RemoteClient* getClient(u16 peer_id);
640         
641         // When called, environment mutex should be locked
642         std::string getPlayerName(u16 peer_id)
643         {
644                 Player *player = m_env->getPlayer(peer_id);
645                 if(player == NULL)
646                         return "[id="+itos(peer_id)+"]";
647                 return player->getName();
648         }
649
650         // When called, environment mutex should be locked
651         PlayerSAO* getPlayerSAO(u16 peer_id)
652         {
653                 Player *player = m_env->getPlayer(peer_id);
654                 if(player == NULL)
655                         return NULL;
656                 return player->getPlayerSAO();
657         }
658
659         /*
660                 Get a player from memory or creates one.
661                 If player is already connected, return NULL
662                 Does not verify/modify auth info and password.
663
664                 Call with env and con locked.
665         */
666         PlayerSAO *emergePlayer(const char *name, u16 peer_id);
667         
668         // Locks environment and connection by its own
669         struct PeerChange;
670         void handlePeerChange(PeerChange &c);
671         void handlePeerChanges();
672
673         u64 getPlayerPrivs(Player *player);
674
675         /*
676                 Variables
677         */
678         
679         // World directory
680         std::string m_path_world;
681         // Path to user's configuration file ("" = no configuration file)
682         std::string m_path_config;
683         // Subgame specification
684         SubgameSpec m_gamespec;
685         // If true, do not allow multiple players and hide some multiplayer
686         // functionality
687         bool m_simple_singleplayer_mode;
688
689         // Thread can set; step() will throw as ServerError
690         MutexedVariable<std::string> m_async_fatal_error;
691         
692         // Some timers
693         float m_liquid_transform_timer;
694         float m_print_info_timer;
695         float m_objectdata_timer;
696         float m_emergethread_trigger_timer;
697         float m_savemap_timer;
698         IntervalLimiter m_map_timer_and_unload_interval;
699         
700         // NOTE: If connection and environment are both to be locked,
701         // environment shall be locked first.
702
703         // Environment
704         ServerEnvironment *m_env;
705         JMutex m_env_mutex;
706         
707         // Connection
708         con::Connection m_con;
709         JMutex m_con_mutex;
710         // Connected clients (behind the con mutex)
711         core::map<u16, RemoteClient*> m_clients;
712
713         // User authentication
714         AuthManager m_authmanager;
715
716         // Bann checking
717         BanManager m_banmanager;
718
719         // Scripting
720         // Envlock and conlock should be locked when using Lua
721         lua_State *m_lua;
722
723         // Item definition manager
724         IWritableItemDefManager *m_itemdef;
725         
726         // Node definition manager
727         IWritableNodeDefManager *m_nodedef;
728         
729         // Craft definition manager
730         IWritableCraftDefManager *m_craftdef;
731         
732         // Event manager
733         EventManager *m_event;
734         
735         // Mods
736         core::list<ModSpec> m_mods;
737         
738         /*
739                 Threads
740         */
741         
742         // A buffer for time steps
743         // step() increments and AsyncRunStep() run by m_thread reads it.
744         float m_step_dtime;
745         JMutex m_step_dtime_mutex;
746
747         // The server mainly operates in this thread
748         ServerThread m_thread;
749         // This thread fetches and generates map
750         EmergeThread m_emergethread;
751         // Queue of block coordinates to be processed by the emerge thread
752         BlockEmergeQueue m_emerge_queue;
753         
754         /*
755                 Time related stuff
756         */
757
758         // Timer for sending time of day over network
759         float m_time_of_day_send_timer;
760         // Uptime of server in seconds
761         MutexedVariable<double> m_uptime;
762         
763         /*
764                 Peer change queue.
765                 Queues stuff from peerAdded() and deletingPeer() to
766                 handlePeerChanges()
767         */
768         enum PeerChangeType
769         {
770                 PEER_ADDED,
771                 PEER_REMOVED
772         };
773         struct PeerChange
774         {
775                 PeerChangeType type;
776                 u16 peer_id;
777                 bool timeout;
778         };
779         Queue<PeerChange> m_peer_change_queue;
780
781         /*
782                 Random stuff
783         */
784         
785         // Mod parent directory paths
786         core::list<std::string> m_modspaths;
787
788         bool m_shutdown_requested;
789
790         /*
791                 Map edit event queue. Automatically receives all map edits.
792                 The constructor of this class registers us to receive them through
793                 onMapEditEvent
794
795                 NOTE: Should these be moved to actually be members of
796                 ServerEnvironment?
797         */
798
799         /*
800                 Queue of map edits from the environment for sending to the clients
801                 This is behind m_env_mutex
802         */
803         Queue<MapEditEvent*> m_unsent_map_edit_queue;
804         /*
805                 Set to true when the server itself is modifying the map and does
806                 all sending of information by itself.
807                 This is behind m_env_mutex
808         */
809         bool m_ignore_map_edit_events;
810         /*
811                 If a non-empty area, map edit events contained within are left
812                 unsent. Done at map generation time to speed up editing of the
813                 generated area, as it will be sent anyway.
814                 This is behind m_env_mutex
815         */
816         VoxelArea m_ignore_map_edit_events_area;
817         /*
818                 If set to !=0, the incoming MapEditEvents are modified to have
819                 this peed id as the disabled recipient
820                 This is behind m_env_mutex
821         */
822         u16 m_ignore_map_edit_events_peer_id;
823
824         friend class EmergeThread;
825         friend class RemoteClient;
826
827         std::map<std::string,MediaInfo> m_media;
828
829         /*
830                 Sounds
831         */
832         std::map<s32, ServerPlayingSound> m_playing_sounds;
833         s32 m_next_sound_id;
834 };
835
836 /*
837         Runs a simple dedicated server loop.
838
839         Shuts down when run is set to false.
840 */
841 void dedicated_server_loop(Server &server, bool &run);
842
843 #endif
844