From 0f46b1255a2dca80866414d974f0fa951bedd4bd Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 12 Nov 2022 07:28:26 +1000 Subject: [PATCH 1/2] Add WorldTileProvider to tshock config This allows the tshock tile providers to be switched via the config instead of cli args via tsapi, for environments where the command line args cannot be changed. --- TShockAPI/Configuration/TShockConfig.cs | 4 ++++ TShockAPI/TShock.cs | 13 +++++++++++++ docs/changelog.md | 1 + 3 files changed, 18 insertions(+) diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index d6f9743e..efeeae86 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -55,6 +55,10 @@ namespace TShockAPI.Configuration [Description("Allows stacks in chests to go beyond the stack limit during world loading.")] public bool IgnoreChestStacksOnLoad = false; + /// Allows changing of the default world tile provider. + [Description("Allows changing of the default world tile provider.")] + public string WorldTileProvider = "default"; + #endregion diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 8dd8c560..8e89a334 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -383,6 +383,19 @@ namespace TShockAPI if (Config.Settings.EnableGeoIP && File.Exists(geoippath)) Geo = new GeoIPCountry(geoippath); + // check if a custom tile provider is to be used + switch(Config.Settings.WorldTileProvider) + { + case "heaptile": + Log.ConsoleInfo(GetString($"Using {nameof(HeapTile)} for tile implementation"), TraceLevel.Info); + Main.tile = new TileProvider(); + break; + case "constileation": + Log.ConsoleInfo(GetString($"Using {nameof(ConstileationProvider)} for tile implementation"), TraceLevel.Info); + Main.tile = new ConstileationProvider(); + break; + } + Log.ConsoleInfo(GetString("TShock {0} ({1}) now running.", Version, VersionCodename)); ServerApi.Hooks.GamePostInitialize.Register(this, OnPostInit); diff --git a/docs/changelog.md b/docs/changelog.md index ac38bf0b..6a65eecf 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -79,6 +79,7 @@ Use past tense when adding new entries; sign your name off when you add or chang ## Upcoming changes * Your changes could be here! +* Added `WorldTileProvider` to the tshock config with values `default`, `constileation` or `heaptile`. This allows tile providers to be changed in environments where CLI args cannot be altered. See the documentation website for more info about these providers. (@SignatureBeef) ## TShock 5.1.2 * Added support for Terraria 1.4.4.8.1 via OTAPI 3.1.19. (@SignatureBeef) From b8afcd874d8c067c950b9c2ffdde132fa03ee17e Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 12 Nov 2022 10:03:42 +1000 Subject: [PATCH 2/2] Add ToLower to WorldTileProvider switch Allows "room for error in capitalization" as per review discussion. --- TShockAPI/TShock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 8e89a334..5ad00f95 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -384,7 +384,7 @@ namespace TShockAPI Geo = new GeoIPCountry(geoippath); // check if a custom tile provider is to be used - switch(Config.Settings.WorldTileProvider) + switch(Config.Settings.WorldTileProvider?.ToLower()) { case "heaptile": Log.ConsoleInfo(GetString($"Using {nameof(HeapTile)} for tile implementation"), TraceLevel.Info);