Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.43k stars 382 forks source link

World Evil Startup Parameter #2631

Closed NotGeri closed 2 years ago

NotGeri commented 2 years ago

Is your feature request related to a problem? Please describe.

It looks like by default in Terraria, you can only choose between the Corrupt, Crimson and Random world evil types once you've reached a certain amount of progress (though I could not find any official source on this so I'm not entirely sure)

When hosting Terraria servers via TShock, since PR #1396 added support to force this option so that you can pick a type no matter how far you've progressed: https://github.com/Pryaxis/TShock/pull/1396 — which is fantastic.

img

Unfortunately, this option is only available when generating a new world with console commands.

Terraria already has a few startup parameters / command-line arguments to automatically create worlds on startup to make things a little bit easier:

(Source: https://terraria.fandom.com/wiki/Server)

As far as I could tell, there is no way currently to do the same with the world evil settings. Having something like -worldevil <crimson/corrupt/random> would be a great addition in my opinion, although I'm not entirely sure whether it's possible.


Describe the solution you'd like

Add a startup parameter to the server which would automatically modify the WorldGen.WorldGenParam_Evil setting to a specific number depending on what's passed in.

For example, adding -worldevil corrupt would modify that to be 0 so that the corrupted world evil is used.

I am unsure whether this is the right solution, or whether there is one at all — but poking around in the source code, this is how the game does it in Terraria.Main.DedServ:

if (SettingsUnlock_WorldEvil) {
    flag2 = true;
    while (flag2) {
        Console.WriteLine(Language.GetTextValue("CLI.Server", versionNumber2));
        Console.WriteLine("");
        Console.WriteLine("1\t" + Language.GetTextValue("CLI.Random"));
        Console.WriteLine("2\t" + Language.GetTextValue("CLI.Corrupt"));
        Console.WriteLine("3\t" + Language.GetTextValue("CLI.Crimson"));
        Console.WriteLine("");
        Console.Write(Language.GetTextValue("CLI.ChooseEvil"));
        string value = Console.ReadLine();
        try {
            switch (Convert.ToInt32(value)) {
            case 1:
                WorldGen.WorldGenParam_Evil = -1;
                flag2 = false;
                break;
            case 2:
                WorldGen.WorldGenParam_Evil = 0;
                flag2 = false;
                break;
            case 3:
                WorldGen.WorldGenParam_Evil = 1;
                flag2 = false;
                break;
            }
        } catch {}
        try {
            Console.Clear();
        } catch {}
    }
}

Describe alternatives you've considered

I'm afraid there really aren't any alternative options, aside from using the standard input to pipe console commands directly. This is not an ideal solution, in my opinion. Of course, if this feature is not currently possible, that is still a route I can consider.


Additional context

None

PotatoCider commented 2 years ago

I think you almost got it. You can add additional command line flags here: https://github.com/Pryaxis/TShock/blob/07becc3c8f4cee37f5dd205e96189519aa4f2f5e/TShockAPI/TShock.cs#L682