Reads in the server config file for a dedicated server Returns true if everything is ok
| 313 | // Reads in the server config file for a dedicated server |
| 314 | // Returns true if everything is ok |
| 315 | int 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 |
| 369 | void StartDedicatedServer() { |
no test coverage detected