Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadDedConfig()

void Terraria.Main.LoadDedConfig ( string configPath)
inline

Definition at line 4560 of file Main.cs.

4561 {
4562 if (!File.Exists(configPath))
4563 {
4564 return;
4565 }
4567 string text;
4568 while ((text = streamReader.ReadLine()) != null)
4569 {
4570 try
4571 {
4572 if (text.Length > 6 && text.Substring(0, 6).ToLower() == "world=")
4573 {
4574 string text2 = text.Substring(6);
4575 try
4576 {
4577 string text3 = Platform.Get<IPathService>().ExpandPathVariables(text2);
4578 new FileInfo(text3);
4581 }
4582 catch
4583 {
4584 }
4585 }
4586 if (text.Length > 5 && text.Substring(0, 5).ToLower() == "port=")
4587 {
4588 string value = text.Substring(5);
4589 try
4590 {
4591 Netplay.ListenPort = Convert.ToInt32(value);
4592 }
4593 catch
4594 {
4595 }
4596 }
4597 if (text.Length > 21 && text.Substring(0, 21).ToLower() == "worldrollbackstokeep=")
4598 {
4599 string value2 = text.Substring(21);
4600 try
4601 {
4603 }
4604 catch
4605 {
4606 }
4607 }
4608 if (text.Length > 11 && text.Substring(0, 11).ToLower() == "maxplayers=")
4609 {
4610 string value3 = text.Substring(11);
4611 try
4612 {
4613 int num = Convert.ToInt32(value3);
4614 if (num <= 255 && num >= 1)
4615 {
4616 SetNetPlayers(num);
4617 }
4618 }
4619 catch
4620 {
4621 }
4622 }
4623 if (text.Length > 11 && text.Substring(0, 9).ToLower() == "priority=" && !Program.LaunchParameters.ContainsKey("-forcepriority"))
4624 {
4625 string value4 = text.Substring(9);
4626 try
4627 {
4628 int num2 = Convert.ToInt32(value4);
4629 if (num2 >= 0 && num2 <= 5)
4630 {
4632 switch (num2)
4633 {
4634 case 0:
4635 currentProcess.PriorityClass = ProcessPriorityClass.RealTime;
4636 break;
4637 case 1:
4638 currentProcess.PriorityClass = ProcessPriorityClass.High;
4639 break;
4640 case 2:
4641 currentProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
4642 break;
4643 case 3:
4644 currentProcess.PriorityClass = ProcessPriorityClass.Normal;
4645 break;
4646 case 4:
4647 currentProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
4648 break;
4649 case 5:
4650 currentProcess.PriorityClass = ProcessPriorityClass.Idle;
4651 break;
4652 }
4653 }
4654 }
4655 catch
4656 {
4657 }
4658 }
4659 if (text.Length > 9 && text.Substring(0, 9).ToLower() == "password=")
4660 {
4661 Netplay.ServerPassword = ConvertFromSafeArgument(text.Substring(9));
4662 }
4663 if (text.Length > 5 && text.Substring(0, 5).ToLower() == "motd=")
4664 {
4665 motd = text.Substring(5);
4666 }
4667 if (text.Length > 5 && text.Substring(0, 5).ToLower() == "lang=")
4668 {
4669 string value5 = text.Substring(5);
4671 }
4672 if (text.Length > 5 && text.Substring(0, 5).ToLower() == "language=")
4673 {
4674 string language = text.Substring(9);
4675 LanguageManager.Instance.SetLanguage(language);
4676 }
4677 if (text.Length >= 10 && text.Substring(0, 10).ToLower() == "worldpath=")
4678 {
4679 string text4 = text.Substring(10);
4680 WorldPath = Platform.Get<IPathService>().ExpandPathVariables(text4);
4681 }
4682 if (text.Length >= 10 && text.Substring(0, 10).ToLower() == "worldname=")
4683 {
4684 worldName = text.Substring(10);
4685 }
4686 if (text.Length >= 5 && text.Substring(0, 5).ToLower() == "seed=")
4687 {
4688 AutogenSeedName = text.Substring(5);
4689 }
4690 if (text.Length > 8 && text.Substring(0, 8).ToLower() == "banlist=")
4691 {
4692 string text5 = text.Substring(8);
4693 Netplay.BanFilePath = Platform.Get<IPathService>().ExpandPathVariables(text5);
4694 }
4695 if (text.Length > 11 && text.Substring(0, 11).ToLower() == "difficulty=")
4696 {
4697 switch (text.Substring(11))
4698 {
4699 case "0":
4700 GameMode = 0;
4701 break;
4702 case "1":
4703 GameMode = 1;
4704 break;
4705 case "2":
4706 GameMode = 2;
4707 break;
4708 case "3":
4709 GameMode = 3;
4710 break;
4711 }
4712 }
4713 if (text.Length > 11 && text.Substring(0, 11).ToLower() == "autocreate=")
4714 {
4715 string worldSize = text.Substring(11);
4717 }
4718 if (text.Length > 7 && text.Substring(0, 7).ToLower() == "secure=" && text.Substring(7) == "1")
4719 {
4720 Netplay.SpamCheck = true;
4721 }
4722 if (text.Length > 5 && text.Substring(0, 5).ToLower() == "upnp=" && text.Substring(5) != "1")
4723 {
4724 Netplay.UseUPNP = false;
4725 }
4726 string text6 = "slowliquids=";
4727 if (text.Length > text6.Length && text.Substring(0, text6.Length).ToLower() == text6 && text.Substring(text6.Length) == "1")
4728 {
4730 }
4731 if (text.Length > 10 && text.Substring(0, 10).ToLower() == "npcstream=")
4732 {
4733 string value6 = text.Substring(10);
4734 try
4735 {
4737 }
4738 catch
4739 {
4740 }
4741 }
4743 }
4744 catch
4745 {
4746 }
4747 }
4748 }
static int ToInt32(object? value)
Definition Convert.cs:1320
static Process GetCurrentProcess()
Definition Process.cs:1107
static bool Exists([NotNullWhen(true)] string? path)
Definition File.cs:97
static WorldFileData GetAllMetadata(string file, bool cloudSave)
Definition WorldFile.cs:243
static int npcStreamSpeed
Definition Main.cs:433
static WorldFileData ActiveWorldFileData
Definition Main.cs:1946
static string motd
Definition Main.cs:1916
static bool Setting_UseReducedMaxLiquids
Definition Main.cs:1733
void autoCreate(string worldSize)
Definition Main.cs:4520
static string worldName
Definition Main.cs:1260
void SetNetPlayers(int mPlayers)
Definition Main.cs:4750
static int GameMode
Definition Main.cs:2685
static int WorldRollingBackupsCountToKeep
Definition Main.cs:1210
static string AutogenSeedName
Definition Main.cs:311
static string ConvertFromSafeArgument(string arg)
Definition Main.cs:4555
static string WorldPath
Definition Main.cs:1948
static string autoGenFileLocation
Definition Main.cs:2275

References Terraria.Main.ActiveWorldFileData, Terraria.Main.autoCreate(), Terraria.Main.autoGenFileLocation, Terraria.Main.AutogenSeedName, Terraria.Main.ConvertFromSafeArgument(), System.IO.File.Exists(), Terraria.Main.GameMode, Terraria.IO.WorldFile.GetAllMetadata(), System.Diagnostics.Process.GetCurrentProcess(), Terraria.Localization.LanguageManager.Instance, Terraria.Program.LaunchParameters, Terraria.Main.motd, Terraria.Main.npcStreamSpeed, Terraria.Main.SetNetPlayers(), Terraria.Main.Setting_UseReducedMaxLiquids, System.text, System.Convert.ToInt32(), Terraria.GameContent.Creative.CreativePowerManager.TryListingPermissionsFrom(), System.value, Terraria.Main.worldName, Terraria.Main.WorldPath, and Terraria.Main.WorldRollingBackupsCountToKeep.

Referenced by Terraria.Initializers.LaunchInitializer.LoadServerParameters().