MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadServerConfigFile

Function LoadServerConfigFile

Descent3/dedicated_server.cpp:315–366  ·  view source on GitHub ↗

Reads in the server config file for a dedicated server Returns true if everything is ok

Source from the content-addressed store, hash-verified

313// Reads in the server config file for a dedicated server
314// Returns true if everything is ok
315int LoadServerConfigFile() {
316 InfFile inf;
317 char operand[INFFILE_LINELEN]; // operand
318 int t = FindArgChar("-dedicated", 'd');
319
320 // int t=FindArg ("-dedicated");
321 if (!t) {
322 PrintDedicatedMessage(TXT_DS_BADCOMMANDLINE);
323 PrintDedicatedMessage("\n");
324 return 0;
325 }
326
327 // Set our defaults
328 MultiResetSettings();
329
330 // Make all ships available
331 for (int i = 0; i < MAX_SHIPS; i++) {
332 if (Ships[i].used)
333 PlayerSetShipPermission(-1, Ships[i].name, true);
334 }
335
336 if (GameArgs[t + 1][0]) {
337 strcpy(Netgame.server_config_name, GameArgs[t + 1]);
338 } else {
339 PrintDedicatedMessage(TXT_DS_MISSINGCONFIG);
340 PrintDedicatedMessage("\n");
341 return 0;
342 }
343
344 // open file
345 if (!inf.Open(Netgame.server_config_name, "[server config file]", DedicatedServerLex)) {
346 PrintDedicatedMessage(TXT_DS_BADCONFIG, Netgame.server_config_name);
347 PrintDedicatedMessage("\n");
348 return 0;
349 }
350
351 // check if valid dedicated server file
352 while (inf.ReadLine()) {
353 int cmd;
354
355 while ((cmd = inf.ParseLine(operand, INFFILE_LINELEN)) > INFFILE_ERROR) {
356 SetCVar(CVars[cmd].varname, operand, true);
357 }
358 }
359
360 inf.Close();
361
362 if (!RunServerConfigs())
363 return 0;
364
365 return 1;
366}
367
368// Starts a dedicated server and loads the server config file
369void StartDedicatedServer() {

Callers 1

InitDedicatedServerFunction · 0.85

Calls 10

FindArgCharFunction · 0.85
PrintDedicatedMessageFunction · 0.85
MultiResetSettingsFunction · 0.85
PlayerSetShipPermissionFunction · 0.85
SetCVarFunction · 0.85
RunServerConfigsFunction · 0.85
ReadLineMethod · 0.80
ParseLineMethod · 0.80
OpenMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected