1 //
2 // Copyright(C) 2005-2014 Simon Howard
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 //
15 // Dedicated server code.
16 //
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 
21 #include "doomtype.h"
22 
23 #include "i_system.h"
24 #include "i_timer.h"
25 
26 #include "m_argv.h"
27 
28 #include "net_defs.h"
29 #include "net_sdl.h"
30 #include "net_server.h"
31 
32 //
33 // People can become confused about how dedicated servers work.  Game
34 // options are specified to the controlling player who is the first to
35 // join a game.  Bomb out with an error message if game options are
36 // specified to a dedicated server.
37 //
38 
39 static char *not_dedicated_options[] =
40 {
41     "-deh", "-iwad", "-cdrom", "-gameversion", "-nomonsters", "-respawn",
42     "-fast", "-altdeath", "-deathmatch", "-turbo", "-merge", "-af", "-as",
43     "-aa", "-file", "-wart", "-skill", "-episode", "-timer", "-avg", "-warp",
44     "-loadgame", "-longtics", "-extratics", "-dup", "-shorttics", NULL,
45 };
46 
CheckForClientOptions(void)47 static void CheckForClientOptions(void)
48 {
49     int i;
50 
51     for (i=0; not_dedicated_options[i] != NULL; ++i)
52     {
53         if (M_CheckParm(not_dedicated_options[i]) > 0)
54         {
55             I_Error("The command line parameter '%s' was specified to a "
56                     "dedicated server.\nGame parameters should be specified "
57                     "to the first player to join a server, \nnot to the "
58                     "server itself. ",
59                     not_dedicated_options[i]);
60         }
61     }
62 }
63 
NET_DedicatedServer(void)64 void NET_DedicatedServer(void)
65 {
66     CheckForClientOptions();
67 
68     NET_SV_Init();
69     NET_SV_AddModule(&net_sdl_module);
70     NET_SV_RegisterWithMaster();
71 
72     while (true)
73     {
74         NET_SV_Run();
75         I_Sleep(10);
76     }
77 }
78 
79