Debian Codegraph @

Descent3/dedicated_server.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
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 3 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
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/dedicated_server.cpp $
21 * $Revision: 1.5 $
22 * $Date: 2004/03/11 03:46:52 $
23 * $Author: kevinb $
24 *
25 * Dedicated server code
26 *
27 * $Log: dedicated_server.cpp,v $
28 * Revision 1.5 2004/03/11 03:46:52 kevinb
29 * Merge of 1.5 code from windows. Hopefully I didn't break anything!
30 *
31 * Revision 1.4 2001/01/13 21:48:45 icculus
32 * patched to (re)compile on win32.
33 *
34 * Revision 1.3 2000/06/03 14:33:49 icculus
35 * Merge with Outrage 1.4 tree...
36 *
37 *
38 * 67 10/17/01 4:52p Matt
39 * Use safe printf() to fix buffer overflow.
40 *
41 * 66 7/09/01 5:45p Matt
42 * Added buffer overflow checking to dedicated server read.
43 *
44 * 65 4/20/00 4:46p Matt
45 * Dedicated server messages now support sending to one player (or team)
46 *
47 * 64 4/20/00 2:23p Matt
48 * Bail from parse routine if null command; used to have an Int3(). Fixed
49 * the crash when ":" was typed in the dedicated server console.
50 *
51 * 63 3/23/00 2:34p Matt
52 * Fixed table error (max string len) that caused crashes when parsing
53 * MultiSettingsFile keywords.
54 *
55 * 62 10/21/99 5:39p Matt
56 * Mac merge
57 *
58 * 61 8/23/99 5:12p Kevin
59 * Fixed double frame interval calling for DMFC
60 *
61 * 60 7/20/99 12:57p Jason
62 * added dedicated server message_of_the_day
63 *
64 * 59 7/15/99 12:47p Jeff
65 * fixed dedicated server quiting when a player logs out from telnet.
66 * Adding logout command
67 *
68 * 58 7/14/99 8:57p Jeff
69 * don't parse out semi-colons
70 *
71 * 57 7/09/99 3:49p Jason
72 * fixed bugs/issues for patch
73 *
74 * 56 7/06/99 5:52p Kevin
75 * PXO & multiplayer fixes for the patch
76 *
77 * 55 6/10/99 4:12p Kevin
78 * Fixed SetLevel in dedicated server for HEAT.NET, and added
79 * level_names.str for level name localization.
80 *
81 * 54 5/24/99 9:55p Jason
82 * fixed stupid dedicated server ship allow thing. I swear I'm going to
83 * start killing people who keep adding things to multiplayer when they
84 * really don't know what they are doing. STOP!
85 *
86 * 53 5/12/99 1:57p Jason
87 * fixed yet more buggy/ugly code
88 *
89 * 52 5/10/99 5:35p Kevin
90 * New command line options for heat and scoring API enhancements
91 *
92 * 51 5/09/99 1:34p Kevin
93 * Added diffuculty level system to multiplayer
94 *
95 * 50 5/07/99 5:00p Jeff
96 * handle errors better with a dedicated server if it couldn't load the
97 * multiplayer dll
98 *
99 * 49 5/02/99 2:32p Kevin
100 * fixed various dedicated server problems.
101 *
102 * $NoKeywords: $
103 */
104
105 #include <cstdarg>
106 #include <cstdio>
107
108 #include <string.h>
109 #include <stdlib.h>
110
111 #if !defined(POSIXcxx . . $ `<built-in>:480:9`!)
112 typedef int socklen_t;
113 #endif
114
115 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
116 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
117 #include "pstring.h"cxx . . $ `<file>/misc/pstring.h`/
118 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
119 #include "inffile.h"cxx . . $ `<file>/cfile/inffile.h`/
120 #include "dedicated_server.h"cxx . . $ `<file>/lib/dedicated_server.h`/
121 #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/
122 #include "args.h"cxx . . $ `<file>/Descent3/args.h`/
123 #include "AppConsole.h"cxx . . $ `<file>/lib/AppConsole.h`/
124 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
125 #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/
126 #include "ui.h"cxx . . $ `<file>/ui/ui.h`/
127 #include "multi_dll_mgr.h"cxx . . $ `<file>/Descent3/multi_dll_mgr.h`/
128 #include "multi_ui.h"cxx . . $ `<file>/Descent3/multi_ui.h`/
129 #include "Mission.h"cxx . . $ `<file>/Descent3/Mission.h`/
130 #include "multi_server.h"cxx . . $ `<file>/Descent3/multi_server.h`/
131 #include "Macros.h"cxx . . $ `<file>/lib/Macros.h`/
132 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
133 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
134 #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/
135 #include "multi_save_settings.h"cxx . . $ `<file>/Descent3/multi_save_settings.h`/
136 #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/
137 #include "rtperformance.h"cxx . . $ `<file>/rtperformance/rtperformance.h`/
138 #include "player.h"cxx . . $ `<file>/Descent3/player.h`/
139 #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/
140 #include "init.h"cxx . . $ `<file>/Descent3/init.h`/
141 #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/
142 #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/
143 #include "networking.h"cxx . . $ `<file>/lib/networking.h`/
144
145
146 bool Dedicated_servercxx . . $ Dedicated_server. = false;
147
148 static int Dedicated_start_levelcxx . . $ Dedicated_start_level. = 1;
149 static int Dummy_dedicated_varcxx . . $ Dummy_dedicated_var.;
150 static char Dummy_dedicated_stringcxx . . $ Dummy_dedicated_string.[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
151
152 // If true, allow remote connections
153 static int Dedicated_allow_remotecxx . . $ Dedicated_allow_remote. = 0;
154 static uint16_tcxx . . $ uint16_t# Dedicated_listen_portcxx . . $ Dedicated_listen_port. = 2092;
155 static char dedicated_telnet_passwordcxx . . $ dedicated_telnet_password.[65];
156 static int Dedicated_num_teamscxx . . $ Dedicated_num_teams. = 1;
157
158 static int RunServerConfigscxx . . $ RunServerConfigs(b126dc7c1de90089).();
159 static int DedicatedServerLexcxx . . $ DedicatedServerLex(5c4306d8553b3696).(const char *command);
160 static void SetCVarNonecxx . . $ SetCVarNone(d4f767463ce0a6b3).(int index);
161
162 extern int CheckMissionForScriptcxx . . $ CheckMissionForScript(60b24ab836da28f5).(char *mission, char *script, int dedicated_server_num_teams);
163
164 extern char Multi_message_of_the_daycxx . . $ Multi_message_of_the_day.[];
165 extern char PXO_hosted_lobby_namecxx . . $ PXO_hosted_lobby_name.[];
166 // These define the types of variables that can be set in the code through
167 // the dedicated server
168
169 static cvar_entrycxx . . $ cvar_entry# CVarscxx . . $ CVars.[] = {
170 {"PPS", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Netgamecxx . . $ Netgame..packets_per_secondcxx . . $ netgame_info#packets_per_second., 2, 20, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 0
171 {"TimeLimit", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Netgamecxx . . $ Netgame..timelimitcxx . . $ netgame_info#timelimit., 0, 10000, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!},
172 {"KillGoal", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Netgamecxx . . $ Netgame..killgoalcxx . . $ netgame_info#killgoal., 0, 10000, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!},
173 {"RespawnTime", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Netgamecxx . . $ Netgame..respawn_timecxx . . $ netgame_info#respawn_time., 0, 10000, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!},
174 {"GameName", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Netgamecxx . . $ Netgame..namecxx . . $ netgame_info#name., -1, NETGAME_NAME_LENcxx . . $ `Descent3/multi_external.h:125:9`!, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 4
175 {"MissionName", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission., -1, MSN_NAMELENcxx . . $ `Descent3/descent.h:181:9`!, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!},
176 {"Scriptname", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname., -1, NETGAME_SCRIPT_LENcxx . . $ `Descent3/multi_external.h:126:9`!, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!},
177 {"ConnectionName", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Netgamecxx . . $ Netgame..connection_namecxx . . $ netgame_info#connection_name., -1, PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!},
178 {"Quit", CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, -1, CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 8
179 {"EndLevel", CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, -1, CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!},
180 #if 0 // def DEMO
181 {"MaxPlayers",CVAR_TYPE_INT,&Netgame.max_players,2,16,CVAR_GAMEINIT}, //10
182 #else
183 {"MaxPlayers", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Netgamecxx . . $ Netgame..max_playerscxx . . $ netgame_info#max_players., 2, MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`!, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 10
184 #endif
185 {"Say", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, 200, CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 11
186 {"UseSmoothing", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., 0, 1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 12
187 {"SendRotVel", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., 0, 1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 13
188 {"MultiSettingsFile", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Dummy_dedicated_stringcxx . . $ Dummy_dedicated_string., -1, 40, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 14
189 {"DisallowPowerup", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Dummy_dedicated_stringcxx . . $ Dummy_dedicated_string., -1, 40, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`! | CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 15
190 {"AllowPowerup", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Dummy_dedicated_stringcxx . . $ Dummy_dedicated_string., -1, 40, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`! | CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 16
191 {"StartRtLog", CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, -1, CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 17
192 {"StopRtLog", CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, -1, CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 18
193 {"PXOUsername", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Auto_login_namecxx . . $ Auto_login_name., -1, 50, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 19
194 {"PXOPassword", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Auto_login_passcxx . . $ Auto_login_pass., -1, 50, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 20
195 {"BrightPlayers", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 21
196 {"Peer2Peer", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 22
197 {"AccurateCollisions", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 23
198 {"ConsolePassword", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &dedicated_telnet_passwordcxx . . $ dedicated_telnet_password., -1, 65, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`! | CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 24
199 {"AllowRemoteConsole", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dedicated_allow_remotecxx . . $ Dedicated_allow_remote., 0, 1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 25
200 {"RemoteConsolePort", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dedicated_listen_portcxx . . $ Dedicated_listen_port., 1, 65535, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 26
201 {"Permissable", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 27
202 {"NumTeams", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dedicated_num_teamscxx . . $ Dedicated_num_teams., 2, 4, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 28
203 {"PXOHostingLobby", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &PXO_hosted_lobby_namecxx . . $ PXO_hosted_lobby_name., -1, 100, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`! | CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 29
204 {"RandomizeRespawn", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 30
205 {"AllowMouselook", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., &Dummy_dedicated_varcxx . . $ Dummy_dedicated_var., -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 31
206 {"AudioTauntDelay", CVAR_TYPE_FLOATcxx . . $ CVAR_TYPE_FLOAT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 32
207 {"SetLevel", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, -1, -1, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`! | CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!}, // 33
208 {"SetDifficulty", CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, 4, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 34
209 {"MOTD", CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING., &Multi_message_of_the_daycxx . . $ Multi_message_of_the_day., -1, HUD_MESSAGE_LENGTHcxx . . $ `Descent3/hud.h:259:9`! * 2, CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!}, // 35
210 };
211
212 #define CVAR_TIMELIMITcxx . . $ `Descent3/dedicated_server.cpp:212:9`! 1
213 #define CVAR_KILLGOALcxx . . $ `Descent3/dedicated_server.cpp:213:9`! 2
214 #define CVAR_QUITcxx . . $ `Descent3/dedicated_server.cpp:214:9`! 8
215 #define CVAR_ENDLEVELcxx . . $ `Descent3/dedicated_server.cpp:215:9`! 9
216 #define CVAR_MAXPLAYERScxx . . $ `Descent3/dedicated_server.cpp:216:9`! 10
217 #define CVAR_MESSAGEcxx . . $ `Descent3/dedicated_server.cpp:217:9`! 11
218 #define CVAR_USESMOOTHINGcxx . . $ `Descent3/dedicated_server.cpp:218:9`! 12
219 #define CVAR_SENDROTVELcxx . . $ `Descent3/dedicated_server.cpp:219:9`! 13
220 #define CVAR_SETTINGScxx . . $ `Descent3/dedicated_server.cpp:220:9`! 14
221 #define CVAR_DISALLOWcxx . . $ `Descent3/dedicated_server.cpp:221:9`! 15
222 #define CVAR_ALLOWcxx . . $ `Descent3/dedicated_server.cpp:222:9`! 16
223 #define CVAR_STARTLOGcxx . . $ `Descent3/dedicated_server.cpp:223:9`! 17
224 #define CVAR_STOPLOGcxx . . $ `Descent3/dedicated_server.cpp:224:9`! 18
225 #define CVAR_BRIGHTPLAYERScxx . . $ `Descent3/dedicated_server.cpp:225:9`! 21
226 #define CVAR_PEER2PEERcxx . . $ `Descent3/dedicated_server.cpp:226:9`! 22
227 #define CVAR_ACCURATE_COLLcxx . . $ `Descent3/dedicated_server.cpp:227:9`! 23
228 #define CVAR_PERMISSABLEcxx . . $ `Descent3/dedicated_server.cpp:228:9`! 27
229 #define CVAR_RANDOMIZERESPAWNcxx . . $ `Descent3/dedicated_server.cpp:229:9`! 30
230 #define CVAR_ALLOWMOUSELOOKERScxx . . $ `Descent3/dedicated_server.cpp:230:9`! 31
231 #define CVAR_AUDIOTAUNTDELAYcxx . . $ `Descent3/dedicated_server.cpp:231:9`! 32
232 #define CVAR_SETLEVELcxx . . $ `Descent3/dedicated_server.cpp:232:9`! 33
233 #define CVAR_SETDIFFcxx . . $ `Descent3/dedicated_server.cpp:233:9`! 34
234 #define CVAR_MOTDcxx . . $ `Descent3/dedicated_server.cpp:234:9`! 35
235
236 #define MAX_CVARScxx . . $ `Descent3/dedicated_server.cpp:236:9`! (sizeof(CVars) / sizeof(cvar_entry))
237
238 // Takes the data that the config file has an runs a server based on that data
239 // Returns true if ok, false if something is wrong
240 int RunServerConfigscxx . . $ RunServerConfigs(b126dc7c1de90089).() {
241 // Load the connection DLL
242 if (LoadMultiDLLcxx . . $ LoadMultiDLL(5c4306d8553b3696).(Netgamecxx . . $ Netgame..connection_namecxx . . $ netgame_info#connection_name.)) {
243 CallMultiDLLcxx . . $ CallMultiDLL(d4f767463ce0a6b3).(MT_AUTO_STARTcxx . . $ `Descent3/multi_dll_mgr.h:94:9`!);
244 if (!MultiDLLGameStartingcxx . . $ MultiDLLGameStarting.) {
245 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_COULDNTINITcxx . . $ `Descent3/stringtable.h:536:9`!, Netgamecxx . . $ Netgame..connection_namecxx . . $ netgame_info#connection_name.);
246 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
247 return 0;
248 } else {
249 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_DLLINITcxx . . $ `Descent3/stringtable.h:537:9`!);
250 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
251 }
252 } else {
253 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_CONNECTLOADERRcxx . . $ `Descent3/stringtable.h:538:9`!, Netgamecxx . . $ Netgame..connection_namecxx . . $ netgame_info#connection_name.);
254 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
255 return 0;
256 }
257
258 // Put in the correct mission names for the oem builds
259 #if (defined(OEM) || defined(DEMO))
260 if (stricmp("polaris.d3l", Netgame.mission) == 0) {
261 strcpy(Netgame.mission_name, "Polaris");
262 } else if (stricmp("taurus.d3l", Netgame.mission) == 0) {
263 strcpy(Netgame.mission_name, "Taurus");
264 } else if (stricmp("thecore.d3l", Netgame.mission) == 0) {
265 strcpy(Netgame.mission_name, "The Core");
266 }
267 #else
268 const char *p = GetMissionNamecxx . . $ GetMissionName(fb58d2e09a2a1ce6).(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.);
269 strcpy(Netgamecxx . . $ Netgame..mission_namecxx . . $ netgame_info#mission_name., p);
270 #endif
271
272 // Load the mission
273 if (!LoadMissioncxx . . $ LoadMission(c5f7da30cbc0f4e9).(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.)) {
274 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_LOADMISSIONERRcxx . . $ `Descent3/stringtable.h:539:9`!, Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.);
275 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
276 return 0;
277 } else {
278 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_MISSIONLOADEDcxx . . $ `Descent3/stringtable.h:540:9`!, Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.);
279 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
280 }
281
282 if (Current_missioncxx . . $ Current_mission..num_levelscxx . . $ tMission#num_levels. >= Dedicated_start_levelcxx . . $ Dedicated_start_level.) {
283 Current_missioncxx . . $ Current_mission..cur_levelcxx . . $ tMission#cur_level. = Dedicated_start_levelcxx . . $ Dedicated_start_level.;
284 } else {
285 Current_missioncxx . . $ Current_mission..cur_levelcxx . . $ tMission#cur_level. = 1;
286 }
287 // Start the actual server
288
289 int teams = CheckMissionForScriptcxx . . $ CheckMissionForScript(60b24ab836da28f5).(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission., Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname., Dedicated_num_teamscxx . . $ Dedicated_num_teams.);
290
291 if (teams == -1) {
292 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_MSNNOTCOMPATIBLEcxx . . $ `Descent3/stringtable.h:838:9`!);
293 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
294 return 0;
295 } else {
296 MultiStartServercxx . . $ MultiStartServer(99469d7ff9a1485a).(0, Netgamecxx . . $ Netgame..scriptnamecxx . . $ netgame_info#scriptname., teams);
297 strcpy(Playerscxx . . $ Players.[0].callsigncxx . . $ player#callsign., TXT_DS_SERVERNAMEcxx . . $ `Descent3/stringtable.h:541:9`!);
298 }
299
300 InitDedicatedSocketcxx . . $ InitDedicatedSocket(ed53e3bbd3fa2f69).(Dedicated_listen_portcxx . . $ Dedicated_listen_port.);
301
302 return 1;
303 }
304
305 int DedicatedServerLexcxx . . $ DedicatedServerLex(5c4306d8553b3696).(const char *command) {
306 for (int i = 0; i < MAX_CVARScxx . . $ `Descent3/dedicated_server.cpp:236:9`!; i++)
307 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(CVars[i].varname, command) == 0)
308 return i;
309
310 return INFFILE_ERRORcxx . . $ INFFILE_ERROR.;
311 }
312
313 // Reads in the server config file for a dedicated server
314 // Returns true if everything is ok
315 int LoadServerConfigFilecxx . . $ LoadServerConfigFile(b126dc7c1de90089).() {
316 InfFilecxx . . $ InfFile# infcxx . . $ InfFile#InfFile(49f6e7a06ebc5aa8).;
317 char operand[INFFILE_LINELENcxx . . $ INFFILE_LINELEN.]; // operand
318 int t = FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-dedicated", 'd');
319
320 // int t=FindArg ("-dedicated");
321 if (!t) {
322 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_BADCOMMANDLINEcxx . . $ `Descent3/stringtable.h:542:9`!);
323 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
324 return 0;
325 }
326
327 // Set our defaults
328 MultiResetSettingscxx . . $ MultiResetSettings(49f6e7a06ebc5aa8).();
329
330 // Make all ships available
331 for (int i = 0; i < MAX_SHIPScxx . . $ `Descent3/ship.h:122:9`!; i++) {
332 if (Shipscxx . . $ Ships.[i].usedcxx . . $ ship#used.)
333 PlayerSetShipPermissioncxx . . $ PlayerSetShipPermission(fb2bb0cf4ad3de37).(-1, Shipscxx . . $ Ships.[i].namecxx . . $ ship#name., true);
334 }
335
336 if (GameArgscxx . . $ GameArgs.[t + 1][0]) {
337 strcpy(Netgamecxx . . $ Netgame..server_config_namecxx . . $ netgame_info#server_config_name., GameArgscxx . . $ GameArgs.[t + 1]);
338 } else {
339 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_MISSINGCONFIGcxx . . $ `Descent3/stringtable.h:543:9`!);
340 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
341 return 0;
342 }
343
344 // open file
345 if (!inf.Opencxx . . $ InfFile#Open(a6c18f6c547e5631).(Netgamecxx . . $ Netgame..server_config_namecxx . . $ netgame_info#server_config_name., "[server config file]", DedicatedServerLexcxx . . $ DedicatedServerLex(5c4306d8553b3696).)) {
346 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_BADCONFIGcxx . . $ `Descent3/stringtable.h:544:9`!, Netgamecxx . . $ Netgame..server_config_namecxx . . $ netgame_info#server_config_name.);
347 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
348 return 0;
349 }
350
351 // check if valid dedicated server file
352 while (inf.ReadLinecxx . . $ InfFile#ReadLine(c9857a73d68e59ba).()) {
353 int cmd;
354
355 while ((cmd = inf.ParseLinecxx . . $ InfFile#ParseLine(6abd07ddb1a912f0).(operand, INFFILE_LINELENcxx . . $ INFFILE_LINELEN.)) > INFFILE_ERRORcxx . . $ INFFILE_ERROR.) {
356 SetCVarcxx . . $ SetCVar(8d00172ec7558ddf).(CVarscxx . . $ CVars.[cmd].varnamecxx . . $ cvar_entry#varname., operand, true);
357 }
358 }
359
360 inf.Closecxx . . $ InfFile#Close(49f6e7a06ebc5aa8).();
361
362 if (!RunServerConfigscxx . . $ RunServerConfigs(b126dc7c1de90089).())
363 return 0;
364
365 return 1;
366 }
367
368 // Starts a dedicated server and loads the server config file
369 void StartDedicatedServercxx . . $ StartDedicatedServer(49f6e7a06ebc5aa8).() {
370 int t = FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-dedicated", 'd');
371 // int t=FindArg ("-dedicated");
372 if (!t)
373 return;
374
375 Dedicated_servercxx . . $ Dedicated_server. = true;
376 }
377
378 // Sets the value for a cvar NONE type
379 void SetCVarNonecxx . . $ SetCVarNone(d4f767463ce0a6b3).(int index) {
380 if (CVarscxx . . $ CVars.[index].typecxx . . $ cvar_entry#type. != CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE.)
381 return; // Only handles ints
382
383 // Do command specific stuff here
384 if (index == CVAR_QUITcxx . . $ `Descent3/dedicated_server.cpp:214:9`!) {
385 if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!) {
386 MultiLeaveGamecxx . . $ MultiLeaveGame(49f6e7a06ebc5aa8).();
387 SetFunctionModecxx . . $ SetFunctionMode(63b1daf7e687142b).(QUIT_MODEcxx . . $ QUIT_MODE.);
388 }
389 }
390
391 if (index == CVAR_ENDLEVELcxx . . $ `Descent3/dedicated_server.cpp:215:9`!) {
392 if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!) {
393 MultiEndLevelcxx . . $ MultiEndLevel(49f6e7a06ebc5aa8).();
394 }
395 }
396
397 if (index == CVAR_STARTLOGcxx . . $ `Descent3/dedicated_server.cpp:223:9`!)
398 rtp_StartLogcxx . . $ rtp_StartLog(49f6e7a06ebc5aa8).();
399
400 if (index == CVAR_STOPLOGcxx . . $ `Descent3/dedicated_server.cpp:224:9`!)
401 rtp_StopLogcxx . . $ rtp_StopLog(49f6e7a06ebc5aa8).();
402 }
403
404 // Sets the value for a cvar INT type
405 void SetCVarIntcxx . . $ SetCVarInt(3e454b8ccf442868).(int index, int val) {
406 void *dest_variable;
407
408 if (CVarscxx . . $ CVars.[index].typecxx . . $ cvar_entry#type. != CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT.)
409 return; // Only handles ints
410
411 dest_variable = CVarscxx . . $ CVars.[index].dest_variablecxx . . $ cvar_entry#dest_variable.;
412
413 if (!(CVarscxx . . $ CVars.[index].var_mincxx . . $ cvar_entry#var_min. == -1 && CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max. == -1)) {
414 if (val < CVarscxx . . $ CVars.[index].var_mincxx . . $ cvar_entry#var_min.)
415 val = (int)CVarscxx . . $ CVars.[index].var_mincxx . . $ cvar_entry#var_min.;
416
417 if (val > CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max.)
418 val = (int)CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max.;
419 }
420
421 // Do command specific stuff here
422 switch (index) {
423 case CVAR_TIMELIMITcxx . . $ `Descent3/dedicated_server.cpp:212:9`!: {
424 if (val > 0)
425 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_TIMERcxx . . $ `Descent3/multi_external.h:226:9`!;
426 else
427 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_TIMERcxx . . $ `Descent3/multi_external.h:226:9`!;
428 } break;
429
430 case CVAR_KILLGOALcxx . . $ `Descent3/dedicated_server.cpp:213:9`!: {
431 if (val > 0)
432 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_KILLGOALcxx . . $ `Descent3/multi_external.h:227:9`!;
433 else
434 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_KILLGOALcxx . . $ `Descent3/multi_external.h:227:9`!;
435 } break;
436
437 case CVAR_MAXPLAYERScxx . . $ `Descent3/dedicated_server.cpp:216:9`!: {
438 if (val > MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`!)
439 val = MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`!;
440 else if (val < 2)
441 val = 2;
442
443 } break;
444
445 case CVAR_BRIGHTPLAYERScxx . . $ `Descent3/dedicated_server.cpp:225:9`!: {
446 if (val)
447 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_BRIGHT_PLAYERScxx . . $ `Descent3/multi_external.h:238:9`!;
448 else
449 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_BRIGHT_PLAYERScxx . . $ `Descent3/multi_external.h:238:9`!;
450 } break;
451
452 case CVAR_USESMOOTHINGcxx . . $ `Descent3/dedicated_server.cpp:218:9`!: {
453 if (val)
454 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_USE_SMOOTHINGcxx . . $ `Descent3/multi_external.h:237:9`!;
455 else
456 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_USE_SMOOTHINGcxx . . $ `Descent3/multi_external.h:237:9`!;
457 } break;
458
459 case CVAR_PEER2PEERcxx . . $ `Descent3/dedicated_server.cpp:226:9`!: {
460 if (val) {
461 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!;
462 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!;
463 } else
464 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!;
465 } break;
466
467 case CVAR_PERMISSABLEcxx . . $ `Descent3/dedicated_server.cpp:228:9`!: {
468 if (val) {
469 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!;
470 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!;
471 } else
472 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!;
473 } break;
474
475 case CVAR_RANDOMIZERESPAWNcxx . . $ `Descent3/dedicated_server.cpp:229:9`!: {
476 if (val) {
477 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_RANDOMIZE_RESPAWNcxx . . $ `Descent3/multi_external.h:241:9`!;
478 } else
479 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_RANDOMIZE_RESPAWNcxx . . $ `Descent3/multi_external.h:241:9`!;
480 } break;
481
482 case CVAR_ACCURATE_COLLcxx . . $ `Descent3/dedicated_server.cpp:227:9`!: {
483 if (val)
484 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_USE_ACC_WEAPcxx . . $ `Descent3/multi_external.h:236:9`!;
485 else
486 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_USE_ACC_WEAPcxx . . $ `Descent3/multi_external.h:236:9`!;
487 } break;
488
489 case CVAR_SENDROTVELcxx . . $ `Descent3/dedicated_server.cpp:219:9`!: {
490 if (val)
491 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_SENDROTVELcxx . . $ `Descent3/multi_external.h:231:9`!;
492 else
493 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_SENDROTVELcxx . . $ `Descent3/multi_external.h:231:9`!;
494 } break;
495 case CVAR_SETLEVELcxx . . $ `Descent3/dedicated_server.cpp:232:9`!: {
496 if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!) {
497 if (val >= 1 && val <= Current_missioncxx . . $ Current_mission..num_levelscxx . . $ tMission#num_levels.) {
498 Multi_next_levelcxx . . $ Multi_next_level. = val;
499 MultiEndLevelcxx . . $ MultiEndLevel(49f6e7a06ebc5aa8).();
500 }
501 } else {
502 if (val >= 1) {
503 Dedicated_start_levelcxx . . $ Dedicated_start_level. = val;
504 }
505 }
506 } break;
507 case CVAR_ALLOWMOUSELOOKERScxx . . $ `Descent3/dedicated_server.cpp:230:9`!: {
508 if (val)
509 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. |= NF_ALLOW_MLOOKcxx . . $ `Descent3/multi_external.h:242:9`!;
510 else
511 Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_ALLOW_MLOOKcxx . . $ `Descent3/multi_external.h:242:9`!;
512 } break;
513 case CVAR_SETDIFFcxx . . $ `Descent3/dedicated_server.cpp:233:9`!: {
514 Netgamecxx . . $ Netgame..difficultycxx . . $ netgame_info#difficulty. = val;
515 } break;
516 }
517
518 if (dest_variable)
519 *((int *)dest_variable) = val;
520 }
521
522 // Sets the value for a cvar FLOAT type
523 void SetCVarFloatcxx . . $ SetCVarFloat(43c79ee2f1b9aefe).(int index, float val) {
524 void *dest_variable;
525
526 if (CVarscxx . . $ CVars.[index].typecxx . . $ cvar_entry#type. != CVAR_TYPE_FLOATcxx . . $ CVAR_TYPE_FLOAT.)
527 return; // Only handles ints
528
529 dest_variable = CVarscxx . . $ CVars.[index].dest_variablecxx . . $ cvar_entry#dest_variable.;
530
531 if (!(CVarscxx . . $ CVars.[index].var_mincxx . . $ cvar_entry#var_min. == -1 && CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max. == -1)) {
532 if (val < CVarscxx . . $ CVars.[index].var_mincxx . . $ cvar_entry#var_min.)
533 val = (float)CVarscxx . . $ CVars.[index].var_mincxx . . $ cvar_entry#var_min.;
534
535 if (val > CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max.)
536 val = (float)CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max.;
537 }
538
539 if (dest_variable)
540 *((float *)dest_variable) = val;
541
542 // Do command specific stuff here
543 switch (index) {
544 case CVAR_AUDIOTAUNTDELAYcxx . . $ `Descent3/dedicated_server.cpp:231:9`!:
545 MultiSetAudioTauntTimecxx . . $ MultiSetAudioTauntTime(1746e8aa98ca1bc0).(val);
546 break;
547 }
548 }
549 // Sets the value for a cvar string type
550 void SetCVarStringcxx . . $ SetCVarString(66835f578de1bcb3).(int index, const char *val) {
551 void *dest_variable;
552
553 if (CVarscxx . . $ CVars.[index].typecxx . . $ cvar_entry#type. != CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING.)
554 return; // Only handles ints
555
556 if (index == CVAR_MESSAGEcxx . . $ `Descent3/dedicated_server.cpp:217:9`!) {
557 // say the message to everyone
558 char str[255];
559
560 int to_whom;
561 const char *msg = GetMessageDestinationcxx . . $ GetMessageDestination(6a735779416056db).(val, &to_whom);
562
563 if (to_whom != MULTI_SEND_MESSAGE_ALLcxx . . $ `Descent3/multi.h:717:9`!)
564 val = msg;
565
566 stdcxx . . $ std/::snprintfcxx . . $ std/snprintf(416d90c494a2998e).(str, sizeof(str), TXT_HUDSAYcxx . . $ `Descent3/stringtable.h:148:9`!, Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].callsigncxx . . $ player#callsign., val);
567
568 MultiSendMessageFromServercxx . . $ MultiSendMessageFromServer(99469d7ff9a1485a).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(0, 128, 255), str, to_whom);
569
570 return;
571 }
572
573 if (index == CVAR_SETTINGScxx . . $ `Descent3/dedicated_server.cpp:220:9`!) {
574 if (MultiLoadSettingscxx . . $ MultiLoadSettings(5c4306d8553b3696).(val)) {
575 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_SETTINGSLOADEDcxx . . $ `Descent3/stringtable.h:545:9`!);
576 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
577 } else {
578 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_SETTINGSERRcxx . . $ `Descent3/stringtable.h:546:9`!);
579 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
580 }
581 }
582
583 if (index == CVAR_DISALLOWcxx . . $ `Descent3/dedicated_server.cpp:221:9`!) {
584 int objid = FindObjectIDNamecxx . . $ FindObjectIDName(5c4306d8553b3696).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(val));
585 if (objid != -1) {
586 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_DISALLOWOBJECTcxx . . $ `Descent3/stringtable.h:547:9`!, Object_infocxx . . $ Object_info.[objid].namecxx . . $ object_info#name.);
587 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
588 Object_infocxx . . $ Object_info.[objid].multi_allowedcxx . . $ object_info#multi_allowed. = 0;
589 }
590 }
591
592 if (index == CVAR_ALLOWcxx . . $ `Descent3/dedicated_server.cpp:222:9`!) {
593 int objid = FindObjectIDNamecxx . . $ FindObjectIDName(5c4306d8553b3696).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(val));
594 if (objid != -1) {
595 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_ALLOWOBJECTScxx . . $ `Descent3/stringtable.h:548:9`!, Object_infocxx . . $ Object_info.[objid].namecxx . . $ object_info#name.);
596 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
597 Object_infocxx . . $ Object_info.[objid].multi_allowedcxx . . $ object_info#multi_allowed. = 1;
598 }
599 }
600
601 dest_variable = CVarscxx . . $ CVars.[index].dest_variablecxx . . $ cvar_entry#dest_variable.;
602
603 if (dest_variable) {
604 strncpy((char *)dest_variable, val, CVarscxx . . $ CVars.[index].var_maxcxx . . $ cvar_entry#var_max.);
605 }
606 }
607
608 // The accessor function that sets the value of a cvar
609 void SetCVarcxx . . $ SetCVar(8d00172ec7558ddf).(const char *cvar_string, const char *cvar_argument, bool game_init) {
610 int i;
611 int done = 0;
612
613 for (i = 0; i < MAX_CVARScxx . . $ `Descent3/dedicated_server.cpp:236:9`! && !done; i++) {
614 if (!(stricmpcxx . . $ `linux/linux_fix.h:43:9`!(cvar_string, CVars[i].varname))) {
615 done = 1;
616
617 if (game_init) {
618 if (!(CVarscxx . . $ CVars.[i].permissionscxx . . $ cvar_entry#permissions. & CVAR_GAMEINITcxx . . $ `lib/dedicated_server.h:22:9`!)) {
619 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_CANTUSEINITcxx . . $ `Descent3/stringtable.h:783:9`!);
620 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
621 continue;
622 }
623
624 } else {
625 if (!(CVarscxx . . $ CVars.[i].permissionscxx . . $ cvar_entry#permissions. & CVAR_GAMEPLAYcxx . . $ `lib/dedicated_server.h:23:9`!)) {
626 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_CANTUSEPLAYcxx . . $ `Descent3/stringtable.h:784:9`!);
627 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
628 continue;
629 }
630 }
631
632 if (CVarscxx . . $ CVars.[i].typecxx . . $ cvar_entry#type. != CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE. && i != CVAR_MESSAGEcxx . . $ `Descent3/dedicated_server.cpp:217:9`!) {
633 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_VARSETcxx . . $ `Descent3/stringtable.h:549:9`!, cvar_string, cvar_argument);
634 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
635 }
636
637 switch (CVarscxx . . $ CVars.[i].typecxx . . $ cvar_entry#type.) {
638 case CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT.: {
639 int val = atoicxx . . $ atoi(f5ecf3191ed0cd93).(cvar_argument);
640 SetCVarIntcxx . . $ SetCVarInt(3e454b8ccf442868).(i, val);
641 } break;
642 case CVAR_TYPE_NONEcxx . . $ CVAR_TYPE_NONE.: {
643 SetCVarNonecxx . . $ SetCVarNone(d4f767463ce0a6b3).(i);
644 } break;
645 case CVAR_TYPE_FLOATcxx . . $ CVAR_TYPE_FLOAT.: {
646 float val = (float)atofcxx . . $ atof(9b0361fcbc284e4f).(cvar_argument);
647 SetCVarFloatcxx . . $ SetCVarFloat(43c79ee2f1b9aefe).(i, val);
648 } break;
649 case CVAR_TYPE_STRINGcxx . . $ CVAR_TYPE_STRING.: {
650 SetCVarStringcxx . . $ SetCVarString(66835f578de1bcb3).(i, cvar_argument);
651 } break;
652 default:
653 Int3cxx . . $ `misc/pserror.h:247:9`!(); // Get Jason, no cvar argument defined
654 break;
655 }
656 }
657 }
658 }
659
660 // The accessor function that sets the value of a cvar...INT only
661 void SetCVarcxx . . $ SetCVar(34d26762b42c433a).(const char *cvar_string, int cvar_argument) {
662 int i;
663 int done = 0;
664
665 for (i = 0; i < MAX_CVARScxx . . $ `Descent3/dedicated_server.cpp:236:9`! && !done; i++) {
666 if (!(stricmpcxx . . $ `linux/linux_fix.h:43:9`!(cvar_string, CVars[i].varname))) {
667 done = 1;
668 switch (CVarscxx . . $ CVars.[i].typecxx . . $ cvar_entry#type.) {
669 case CVAR_TYPE_INTcxx . . $ CVAR_TYPE_INT.: {
670 SetCVarIntcxx . . $ SetCVarInt(3e454b8ccf442868).(i, cvar_argument);
671 } break;
672
673 default:
674 Int3cxx . . $ `misc/pserror.h:247:9`!(); // You are using the wrong accessor function...this is for INTS only!
675 break;
676 }
677 }
678 }
679 }
680
681 // The accessor function that sets the value of a cvar...FLOAT only
682 void SetCVarcxx . . $ SetCVar(42eacfea086a5352).(const char *cvar_string, float cvar_argument) {
683 int i;
684 int done = 0;
685
686 for (i = 0; i < MAX_CVARScxx . . $ `Descent3/dedicated_server.cpp:236:9`! && !done; i++) {
687 if (!(stricmpcxx . . $ `linux/linux_fix.h:43:9`!(cvar_string, CVars[i].varname))) {
688 done = 1;
689 switch (CVarscxx . . $ CVars.[i].typecxx . . $ cvar_entry#type.) {
690 case CVAR_TYPE_FLOATcxx . . $ CVAR_TYPE_FLOAT.: {
691 SetCVarFloatcxx . . $ SetCVarFloat(43c79ee2f1b9aefe).(i, cvar_argument);
692 } break;
693
694 default:
695 Int3cxx . . $ `misc/pserror.h:247:9`!(); // You are using the wrong accessor function...this is for INTS only!
696 break;
697 }
698 }
699 }
700 }
701
702 void ParseLinecxx . . $ ParseLine(dd70b6a3753abd6d).(char *srcline, char *command, char *operand, int cmdlen, int oprlen) {
703 // tokenize line.
704 char *opr, *cmd;
705
706 if (strlen(srcline) == 0)
707 return;
708
709 // parse out command and operand (command=str)
710 // m_lineptr = command, opr = operand, nextcmd = next lineptr.
711 cmd = strtok(srcline, " \t=:");
712 if (cmd)
713 opr = strtok(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, "");
714 else
715 return; // null command, so bail
716
717 // clean out trailing and preceeding trash (tabs, spaces, etc)
718 CleanupStrcxx . . $ CleanupStr(55abe9014c6d0e39).(command, cmd, cmdlen);
719 if (opr)
720 CleanupStrcxx . . $ CleanupStr(55abe9014c6d0e39).(operand, opr, oprlen);
721 else
722 operand[0] = 0;
723 }
724
725 // Called once per frame for the dedicated server
726 void DoDedicatedServerFramecxx . . $ DoDedicatedServerFrame(49f6e7a06ebc5aa8).() {
727 char str[255];
728 char command[255] = {}; // operand
729 char operand[255]; // operand
730
731 ListenDedicatedSocketcxx . . $ ListenDedicatedSocket(49f6e7a06ebc5aa8).();
732 DedicatedReadTelnetcxx . . $ DedicatedReadTelnet(49f6e7a06ebc5aa8).();
733
734 // CallGameDLL (EVT_GAME_INTERVAL,&DLLInfo);
735
736 if (ServerTimeoutcxx . . $ ServerTimeout.) {
737 float now = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!();
738 int sincelastpacket = ((float)(now - LastPacketReceivedcxx . . $ LastPacketReceived.)) / 60;
739 // See if it's time to shutdown...
740 if (sincelastpacket > ServerTimeoutcxx . . $ ServerTimeout.) {
741 int quitno = DedicatedServerLexcxx . . $ DedicatedServerLex(5c4306d8553b3696).("Quit");
742 if (quitno >= 0)
743 SetCVarcxx . . $ SetCVar(8d00172ec7558ddf).(CVarscxx . . $ CVars.[quitno].varnamecxx . . $ cvar_entry#varname., "", false);
744 }
745 }
746
747 bool new_command = con_Inputcxx . . $ con_Input(37e8d18a243bba77).(str, 255);
748
749 if (!new_command)
750 return;
751
752 if (str[0] == '$') {
753 DLLInfocxx . . $ DLLInfo..input_stringcxx . . $ dllinfo#input_string. = str;
754 CallGameDLLcxx . . $ CallGameDLL(32ca0c0c7dbc2fcf).(EVT_CLIENT_INPUT_STRINGcxx . . $ `lib/d3events.h:106:9`!, &DLLInfocxx . . $ DLLInfo.);
755 return;
756 }
757
758 ParseLinecxx . . $ ParseLine(dd70b6a3753abd6d).(str, command, operand, 255, 255);
759
760 if (!command[0])
761 return;
762
763 int index = DedicatedServerLexcxx . . $ DedicatedServerLex(5c4306d8553b3696).(command);
764
765 if (index < 0) {
766 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_BADCOMMANDcxx . . $ `Descent3/stringtable.h:550:9`!);
767 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
768 return;
769 }
770
771 // Everything ok, set command
772 SetCVarcxx . . $ SetCVar(8d00172ec7558ddf).(CVarscxx . . $ CVars.[index].varnamecxx . . $ cvar_entry#varname., operand, false);
773 }
774
775 // Prints a message to the console if the dedicated server is active
776 void PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(const char *fmt, ...) {
777 if (!Dedicated_servercxx . . $ Dedicated_server.)
778 return;
779
780 char buf[CON_MAX_STRINGLENcxx . . $ `lib/AppConsole.h:44:9`!];
781 stdcxx . . $ std/::va_listcxx . . $ std/va_list# args;
782
783 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(args, fmt);
784 stdcxx . . $ std/::vsnprintfcxx . . $ std/vsnprintf(348eb892742d8727).(buf, CON_MAX_STRINGLENcxx . . $ `lib/AppConsole.h:44:9`!, fmt, args);
785 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(args);
786
787 con_Printfcxx . . $ con_Printf(326aeb464d16410c).(buf);
788 DedicatedSocketputscxx . . $ DedicatedSocketputs(fda57c8427c60377).(buf);
789 }
790
791 #if defined(POSIXcxx . . $ `<built-in>:480:9`!)
792 #include <netinet/in.h>
793 #include <arpa/inet.h>
794 #include <sys/socket.h>
795 #include <unistd.h>
796
797 #include "linux_fix.h"cxx . . $ `<file>/linux/linux_fix.h`/
798 #include "errno.h"
799 #define BOOLcxx . . $ `Descent3/dedicated_server.cpp:799:9`! bool
800 #ifndef SOCKETcxx . . $ `lib/networking.h:217:9`!
801 #define SOCKET int
802 #endif
803 #define SOCKADDR_INcxx . . $ `Descent3/dedicated_server.cpp:803:9`! sockaddr_in
804 #define SOCKADDRcxx . . $ `Descent3/dedicated_server.cpp:804:9`! sockaddr
805 #define INVALID_SOCKETcxx . . $ `Descent3/dedicated_server.cpp:805:9`! -1
806
807 // Winsock = sockets error translation
808
809 #define WSAEWOULDBLOCKcxx . . $ `Descent3/dedicated_server.cpp:809:9`! EWOULDBLOCK
810 #define WSAEINVALcxx . . $ `Descent3/dedicated_server.cpp:810:9`! EINVAL
811 #define WSAENOPROTOOPTcxx . . $ `Descent3/dedicated_server.cpp:811:9`! ENOPROTOOPT
812
813 #ifndef WSAGetLastErrorcxx . . $ `lib/networking.h:241:9`!
814 #define WSAGetLastError() errno
815 #endif
816
817 #define SOCKET_ERRORcxx . . $ `Descent3/dedicated_server.cpp:817:9`! -1
818
819 #endif
820
821 struct dedicated_socketcxx . . $ dedicated_socket# {
822 SOCKETcxx . . $ `lib/networking.h:217:9`! sockcxx . . $ dedicated_socket#sock.;
823 SOCKADDR_INcxx . . $ `Descent3/dedicated_server.cpp:803:9`! addrcxx . . $ dedicated_socket#addr.;
824 char inputcxx . . $ dedicated_socket#input.[255];
825 bool validatedcxx . . $ dedicated_socket#validated.;
826 dedicated_socketcxx . . $ dedicated_socket# *prevcxx . . $ dedicated_socket#prev.;
827 dedicated_socketcxx . . $ dedicated_socket# *nextcxx . . $ dedicated_socket#next.;
828 };
829
830 dedicated_socketcxx . . $ dedicated_socket# *Head_sockcxx . . $ Head_sock. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
831
832 SOCKETcxx . . $ `lib/networking.h:217:9`! dedicated_listen_socketcxx . . $ dedicated_listen_socket. = INVALID_SOCKETcxx . . $ `Descent3/dedicated_server.cpp:805:9`!;
833
834 #define DEDICATED_LOGIN_PROMPTcxx . . $ `Descent3/dedicated_server.cpp:834:9`! TXT_DS_ENTERPASScxx . . $ `Descent3/stringtable.h:551:9`!
835
836 void InitDedicatedSocketcxx . . $ InitDedicatedSocket(ed53e3bbd3fa2f69).(uint16_tcxx . . $ uint16_t# port) {
837 SOCKADDR_INcxx . . $ `Descent3/dedicated_server.cpp:803:9`! sock_addr;
838
839 memset(&sock_addr, 0, sizeof(SOCKADDR_INcxx . . $ `Descent3/dedicated_server.cpp:803:9`!));
840 sock_addr.sin_family = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
841 uint32_tcxx . . $ uint32_t# my_ip;
842 my_ip = nw_GetThisIPcxx . . $ nw_GetThisIP(db52760e79bf9054).();
843 memcpy(&sock_addr.sin_addr.s_addr, &my_ip, sizeof(uint32_tcxx . . $ uint32_t#));
844 sock_addr.sin_port = htons(port);
845
846 dedicated_listen_socketcxx . . $ dedicated_listen_socket. = socket(AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, 0);
847
848 if (INVALID_SOCKETcxx . . $ `Descent3/dedicated_server.cpp:805:9`! == dedicated_listen_socketcxx . . $ dedicated_listen_socket.) {
849 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Unable to create listen socket for dedicated server!\n");
850 return;
851 }
852 if (SOCKET_ERRORcxx . . $ `Descent3/dedicated_server.cpp:817:9`! == bind(dedicated_listen_socketcxx . . $ dedicated_listen_socket., (SOCKADDRcxx . . $ `Descent3/dedicated_server.cpp:804:9`! *)&sock_addr, sizeof(sock_addr))) {
853 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Unable to bind listen socket for dedicated server!\n");
854 return;
855 }
856 if (listen(dedicated_listen_socketcxx . . $ dedicated_listen_socket., 1)) {
857 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Unable to listen on dedicated server socket!\n");
858 return;
859 }
860 make_nonblockingcxx . . $ make_nonblocking(7864480464b09eea).(dedicated_listen_socketcxx . . $ dedicated_listen_socket.);
861 }
862
863 void ListenDedicatedSocketcxx . . $ ListenDedicatedSocket(49f6e7a06ebc5aa8).(void) {
864 SOCKETcxx . . $ `lib/networking.h:217:9`! incoming_socket;
865 SOCKADDR_INcxx . . $ `Descent3/dedicated_server.cpp:803:9`! conn_addr;
866 // int addrlen = sizeof(conn_addr);
867 socklen_t addrlen = sizeof(conn_addr);
868 incoming_socket = accept(dedicated_listen_socketcxx . . $ dedicated_listen_socket., (SOCKADDRcxx . . $ `Descent3/dedicated_server.cpp:804:9`! *)&conn_addr, &addrlen);
869 if (INVALID_SOCKETcxx . . $ `Descent3/dedicated_server.cpp:805:9`! != incoming_socket) {
870 // Make the socket non-blocking
871
872 make_nonblockingcxx . . $ make_nonblocking(7864480464b09eea).(incoming_socket);
873
874 if (!Dedicated_allow_remotecxx . . $ Dedicated_allow_remote.) {
875 // Check to see if this came in from the local address
876 uint32_tcxx . . $ uint32_t# localhost = inet_addr("127.0.0.1");
877 if (memcmp(&localhost, &conn_addr.sin_addr, sizeof(localhost)) != 0) {
878 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Rejecting connection from remote host!\n");
879 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_REJECTREMOTEcxx . . $ `Descent3/stringtable.h:552:9`!, inet_ntoa(conn_addr.sin_addr));
880 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
881 shutdown(incoming_socket, 2);
882 #if defined(WIN32)
883 closesocket(incoming_socket);
884 #else
885 close(incoming_socket);
886 #endif
887 return;
888 }
889 }
890 // At this point it's considered a valid connection
891 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_NEWCONNECTcxx . . $ `Descent3/stringtable.h:553:9`!, inet_ntoa(conn_addr.sin_addr));
892 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
893 dedicated_socketcxx . . $ dedicated_socket# *new_socket;
894 new_socket = (dedicated_socketcxx . . $ dedicated_socket# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(dedicated_socket));
895 if (Head_sockcxx . . $ Head_sock.)
896 Head_sockcxx . . $ Head_sock.->prevcxx . . $ dedicated_socket#prev. = new_socket;
897 new_socket->nextcxx . . $ dedicated_socket#next. = Head_sockcxx . . $ Head_sock.;
898 new_socket->prevcxx . . $ dedicated_socket#prev. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
899 Head_sockcxx . . $ Head_sock. = new_socket;
900 memcpy(&new_socket->addrcxx . . $ dedicated_socket#addr., &conn_addr, sizeof(new_socket->addrcxx . . $ dedicated_socket#addr.));
901 new_socket->inputcxx . . $ dedicated_socket#input.[0] = '\0';
902 new_socket->sockcxx . . $ dedicated_socket#sock. = incoming_socket;
903 new_socket->validatedcxx . . $ dedicated_socket#validated. = false;
904 // Give the new connection the login prompt
905 send(new_socket->sockcxx . . $ dedicated_socket#sock., DEDICATED_LOGIN_PROMPTcxx . . $ `Descent3/dedicated_server.cpp:834:9`!, strlen(DEDICATED_LOGIN_PROMPTcxx . . $ `Descent3/dedicated_server.cpp:834:9`!) + 1, 0);
906 }
907 }
908
909 void DedicatedSocketputscxx . . $ DedicatedSocketputs(fda57c8427c60377).(char *str) {
910 char newstr[300];
911 char buf[2];
912
913 memset(newstr, 0, 300);
914 int len = strlen(str);
915 for (int i = 0; i < len; i++) {
916 if (str[i] == '\n') {
917 strcat(newstr, "\r\n");
918 } else {
919 buf[0] = str[i];
920 buf[1] = '\0';
921 strcat(newstr, buf);
922 }
923 }
924
925 dedicated_socketcxx . . $ dedicated_socket# *conn;
926 conn = Head_sockcxx . . $ Head_sock.;
927 while (conn) {
928 if (conn->validatedcxx . . $ dedicated_socket#validated.) {
929 send(conn->sockcxx . . $ dedicated_socket#sock., newstr, strlen(newstr) + 1, 0);
930 }
931 conn = conn->nextcxx . . $ dedicated_socket#next.;
932 }
933 }
934
935 dedicated_socketcxx . . $ dedicated_socket# *DedicatedLogoutTelnetcxx . . $ DedicatedLogoutTelnet(83206e93e725f949).(dedicated_socketcxx . . $ dedicated_socket# *conn) {
936 // user is no longer valid (so we don't attempt to send them a message
937 conn->validatedcxx . . $ dedicated_socket#validated. = false;
938
939 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_REMOTECLOSEcxx . . $ `Descent3/stringtable.h:554:9`!, inet_ntoa(conn->addrcxx . . $ dedicated_socket#addr..sin_addr));
940 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
941
942 shutdown(conn->sockcxx . . $ dedicated_socket#sock., 2);
943 #if defined(WIN32)
944 closesocket(conn->sock);
945 #else
946 close(conn->sockcxx . . $ dedicated_socket#sock.);
947 #endif
948
949 dedicated_socketcxx . . $ dedicated_socket# *prev;
950 prev = conn->prevcxx . . $ dedicated_socket#prev.;
951 if (prev) {
952 prev->nextcxx . . $ dedicated_socket#next. = conn->nextcxx . . $ dedicated_socket#next.;
953 } else {
954 Head_sockcxx . . $ Head_sock. = conn->nextcxx . . $ dedicated_socket#next.;
955 if (Head_sockcxx . . $ Head_sock.)
956 Head_sockcxx . . $ Head_sock.->prevcxx . . $ dedicated_socket#prev. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
957 }
958
959 mem_freecxx . . $ `mem/mem.h:80:9`!(conn);
960 return prev;
961 }
962
963 void DedicatedReadTelnetcxx . . $ DedicatedReadTelnet(49f6e7a06ebc5aa8).(void) {
964 dedicated_socketcxx . . $ dedicated_socket# *conn;
965 char buf[5];
966 conn = Head_sockcxx . . $ Head_sock.;
967
968 while (conn) {
969 int bytesread = 1;
970 while (bytesread >= 0 && conn) {
971 // Read one byte at a time, looking for a CR
972 bytesread = recv(conn->sockcxx . . $ dedicated_socket#sock., buf, 1, 0);
973 if (bytesread == 0) {
974 // Connection closed. Remove it from the list, and inform the other(?) users.
975 conn = DedicatedLogoutTelnetcxx . . $ DedicatedLogoutTelnet(83206e93e725f949).(conn);
976 break;
977 } else if (bytesread > 0) {
978 buf[1] = '\0';
979 // When we see a CR, process the line
980 if ((buf[0] == 0x0a) || (buf[0] == 0x0d)) {
981 if (conn->inputcxx . . $ dedicated_socket#input.[0] == 0) {
982 continue;
983 }
984 send(conn->sockcxx . . $ dedicated_socket#sock., "\r\n", strlen("\r\n"), 0);
985 if (conn->validatedcxx . . $ dedicated_socket#validated.) {
986 char command[255] = {}; // operand
987 char operand[255]; // operand
988
989 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(conn->input, "logout")) {
990 // log the connection out
991 conn = DedicatedLogoutTelnetcxx . . $ DedicatedLogoutTelnet(83206e93e725f949).(conn);
992 } else {
993 // Process the string
994 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("[%s] %s\n", inet_ntoa(conn->addrcxx . . $ dedicated_socket#addr..sin_addr), conn->inputcxx . . $ dedicated_socket#input.);
995 if (conn->inputcxx . . $ dedicated_socket#input.[0] == '$') {
996 DLLInfocxx . . $ DLLInfo..input_stringcxx . . $ dllinfo#input_string. = conn->inputcxx . . $ dedicated_socket#input.;
997 CallGameDLLcxx . . $ CallGameDLL(32ca0c0c7dbc2fcf).(EVT_CLIENT_INPUT_STRINGcxx . . $ `lib/d3events.h:106:9`!, &DLLInfocxx . . $ DLLInfo.);
998 conn->inputcxx . . $ dedicated_socket#input.[0] = '\0';
999 return;
1000 }
1001
1002 ParseLinecxx . . $ ParseLine(dd70b6a3753abd6d).(conn->inputcxx . . $ dedicated_socket#input., command, operand, 255, 255);
1003 conn->inputcxx . . $ dedicated_socket#input.[0] = '\0';
1004 if (!command[0])
1005 return;
1006
1007 int index = DedicatedServerLexcxx . . $ DedicatedServerLex(5c4306d8553b3696).(command);
1008
1009 if (index < 0) {
1010 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_BADCOMMANDcxx . . $ `Descent3/stringtable.h:550:9`!);
1011 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
1012 return;
1013 }
1014
1015 // Everything ok, set command
1016 SetCVarcxx . . $ SetCVar(8d00172ec7558ddf).(CVarscxx . . $ CVars.[index].varnamecxx . . $ cvar_entry#varname., operand, false);
1017 }
1018 } else {
1019 // All we want to see from them is the correct password
1020 if (strcmp(conn->inputcxx . . $ dedicated_socket#input., dedicated_telnet_passwordcxx . . $ dedicated_telnet_password.) == 0) {
1021 // They logged in ok!
1022 conn->validatedcxx . . $ dedicated_socket#validated. = true;
1023 send(conn->sockcxx . . $ dedicated_socket#sock., "\r\n", strlen("\r\n") + 1, 0);
1024 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_REMOTELOGGEDINcxx . . $ `Descent3/stringtable.h:555:9`!, inet_ntoa(conn->addrcxx . . $ dedicated_socket#addr..sin_addr));
1025 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
1026 conn->inputcxx . . $ dedicated_socket#input.[0] = '\0';
1027 } else {
1028 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).(TXT_DS_BADPASScxx . . $ `Descent3/stringtable.h:556:9`!, inet_ntoa(conn->addrcxx . . $ dedicated_socket#addr..sin_addr));
1029 PrintDedicatedMessagecxx . . $ PrintDedicatedMessage(326aeb464d16410c).("\n");
1030 shutdown(conn->sockcxx . . $ dedicated_socket#sock., 2);
1031 #if defined(WIN32)
1032 closesocket(conn->sock);
1033 #else
1034 close(conn->sockcxx . . $ dedicated_socket#sock.);
1035 #endif
1036 }
1037 }
1038 } else {
1039 if (buf[0] == 8) {
1040 // handle backspace
1041 char delstr[5];
1042 delstr[0] = 8;
1043 delstr[1] = ' ';
1044 delstr[2] = 8;
1045 delstr[3] = '\0';
1046 conn->inputcxx . . $ dedicated_socket#input.[strlen(conn->inputcxx . . $ dedicated_socket#input.) - 1] = '\0';
1047 buf[1] = '\0';
1048 send(conn->sockcxx . . $ dedicated_socket#sock., delstr, strlen(delstr), 0);
1049 } else {
1050 if (strlen(conn->inputcxx . . $ dedicated_socket#input.) + bytesread >= sizeof(conn->inputcxx . . $ dedicated_socket#input.)) {
1051 conn->inputcxx . . $ dedicated_socket#input.[0] = 0;
1052 const char *s = "\n\rCommand line too long\n\r";
1053 send(conn->sockcxx . . $ dedicated_socket#sock., s, strlen(s), 0);
1054 } else {
1055 strcat(conn->inputcxx . . $ dedicated_socket#input., buf);
1056 send(conn->sockcxx . . $ dedicated_socket#sock., buf, 1, 0);
1057 }
1058 }
1059 }
1060 }
1061 }
1062 if (conn)
1063 conn = conn->nextcxx . . $ dedicated_socket#next.;
1064 }
1065 }