diff --git a/Patcher/.gitignore b/.gitignore similarity index 100% rename from Patcher/.gitignore rename to .gitignore diff --git a/Patcher/patches/Terraria/Terraria.csproj.patch b/Patcher/patches/Terraria/Terraria.csproj.patch deleted file mode 100644 index 63e133bc989..00000000000 --- a/Patcher/patches/Terraria/Terraria.csproj.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- src/merged\Terraria.csproj -+++ src/Terraria\Terraria.csproj -@@ -26,9 +26,11 @@ - true - - -- CLIENT -+ true -+ DEBUG;CLIENT - - -+ true - CLIENT - - -@@ -38,11 +40,20 @@ - - - -- -- -+ -+ Terraria.Libraries\Steamworks.NET\Steamworks.NET.dll -+ False -+ -+ -+ Terraria.Libraries\JSON.NET\Newtonsoft.Json.dll -+ False -+ - - -- -+ -+ Terraria.Libraries\DotNetZip\Ionic.Zip.CF.dll -+ False -+ - - - - diff --git a/Patcher/patches/Terraria/Terraria/HitTile.cs.patch b/Patcher/patches/Terraria/Terraria/HitTile.cs.patch deleted file mode 100644 index eb822988a84..00000000000 --- a/Patcher/patches/Terraria/Terraria/HitTile.cs.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- src/merged\Terraria\HitTile.cs -+++ src/Terraria\Terraria\HitTile.cs -@@ -148,7 +148,15 @@ - goto IL_EE; - } - } -- goto IL_E1; -+ for (int k = 20; k > 1; k--) -+ { -+ int num = this.order[k - 1]; -+ this.order[k - 1] = this.order[k]; -+ this.order[k] = num; -+ } -+ this.order[1] = tileId; -+ goto IL_EE; -+ //goto IL_E1; - } - this.bufferLocation = this.order[20]; - this.data[this.bufferLocation].Clear(); -@@ -182,7 +190,8 @@ - return; - } - } -- goto IL_47; -+ this.order[20] = tileId; -+ //goto IL_47; - } - - public void Prune() - diff --git a/Patcher/patches/Terraria/TerrariaServer.csproj.patch b/Patcher/patches/Terraria/TerrariaServer.csproj.patch deleted file mode 100644 index 86bbae90443..00000000000 --- a/Patcher/patches/Terraria/TerrariaServer.csproj.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- src/merged\TerrariaServer.csproj -+++ src/Terraria\TerrariaServer.csproj -@@ -26,23 +26,34 @@ - true - - -- SERVER -+ true -+ DEBUG;SERVER - - -+ true - SERVER - - - - -- -+ -+ Terraria.Libraries\Steamworks.NET\Steamworks.NET.dll -+ False -+ - - - -- -+ -+ Terraria.Libraries\JSON.NET\Newtonsoft.Json.dll -+ False -+ - - - -- -+ -+ Terraria.Libraries\DotNetZip\Ionic.Zip.CF.dll -+ False -+ - - - - diff --git a/Patcher/patches/tModLoader/Icon.ico b/Patcher/patches/tModLoader/Icon.ico deleted file mode 100644 index b3f9c83ee57..00000000000 Binary files a/Patcher/patches/tModLoader/Icon.ico and /dev/null differ diff --git a/Patcher/patches/tModLoader/Terraria.Achievements/Achievement.cs.patch b/Patcher/patches/tModLoader/Terraria.Achievements/Achievement.cs.patch deleted file mode 100644 index 843fb3de8a3..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Achievements/Achievement.cs.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- src/Terraria\Terraria.Achievements\Achievement.cs -+++ src/tModLoader\Terraria.Achievements\Achievement.cs -@@ -6,7 +6,7 @@ - - namespace Terraria.Achievements - { -- [JsonObject(MemberSerialization.OptIn)] -+ [JsonObject] - public class Achievement - { - public delegate void AchievementCompleted(Achievement achievement); - diff --git a/Patcher/patches/tModLoader/Terraria.Achievements/AchievementCondition.cs.patch b/Patcher/patches/tModLoader/Terraria.Achievements/AchievementCondition.cs.patch deleted file mode 100644 index 9f5918769e5..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Achievements/AchievementCondition.cs.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- src/Terraria\Terraria.Achievements\AchievementCondition.cs -+++ src/tModLoader\Terraria.Achievements\AchievementCondition.cs -@@ -4,7 +4,7 @@ - - namespace Terraria.Achievements - { -- [JsonObject(MemberSerialization.OptIn)] -+ [JsonObject] - public abstract class AchievementCondition - { - public delegate void AchievementUpdate(AchievementCondition condition); - diff --git a/Patcher/patches/tModLoader/Terraria.GameContent.UI.Elements/UIHeader.cs.patch b/Patcher/patches/tModLoader/Terraria.GameContent.UI.Elements/UIHeader.cs.patch deleted file mode 100644 index 2c2ea960f68..00000000000 --- a/Patcher/patches/tModLoader/Terraria.GameContent.UI.Elements/UIHeader.cs.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- src/Terraria\Terraria.GameContent.UI.Elements\UIHeader.cs -+++ src/tModLoader\Terraria.GameContent.UI.Elements\UIHeader.cs -@@ -20,11 +20,9 @@ - if (this._text != value) - { - this._text = value; --#if CLIENT - Vector2 vector = Main.fontDeathText.MeasureString(this.Text); - this.Width.Pixels = vector.X; - this.Height.Pixels = vector.Y; --#endif - this.Width.Precent = 0f; - this.Height.Precent = 0f; - this.Recalculate(); - diff --git a/Patcher/patches/tModLoader/Terraria.Graphics.Capture/CaptureCamera.cs.patch b/Patcher/patches/tModLoader/Terraria.Graphics.Capture/CaptureCamera.cs.patch deleted file mode 100644 index d463ee7469b..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Graphics.Capture/CaptureCamera.cs.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- src/Terraria\Terraria.Graphics.Capture\CaptureCamera.cs -+++ src/tModLoader\Terraria.Graphics.Capture\CaptureCamera.cs -@@ -320,7 +320,6 @@ - - public void Dispose() - { --#if CLIENT - Monitor.Enter(this._captureLock); - if (this._isDisposed) - { -@@ -335,7 +334,6 @@ - CaptureCamera.CameraExists = false; - this._isDisposed = true; - Monitor.Exit(this._captureLock); --#endif - } - } - } - diff --git a/Patcher/patches/tModLoader/Terraria.Graphics.Capture/CaptureManager.cs.patch b/Patcher/patches/tModLoader/Terraria.Graphics.Capture/CaptureManager.cs.patch deleted file mode 100644 index 7fbd8de2998..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Graphics.Capture/CaptureManager.cs.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- src/Terraria\Terraria.Graphics.Capture\CaptureManager.cs -+++ src/tModLoader\Terraria.Graphics.Capture\CaptureManager.cs -@@ -14,11 +14,7 @@ - { - get - { --#if CLIENT - return this._camera.IsCapturing; --#else -- return false; --#endif - } - } - -@@ -52,9 +48,7 @@ - public CaptureManager() - { - this._interface = new CaptureInterface(); --#if CLIENT - this._camera = new CaptureCamera(Main.instance.GraphicsDevice); --#endif - } - - public void Scrolling() - diff --git a/Patcher/patches/tModLoader/Terraria.Graphics/TextureManager.cs.patch b/Patcher/patches/tModLoader/Terraria.Graphics/TextureManager.cs.patch deleted file mode 100644 index 0c1a958f240..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Graphics/TextureManager.cs.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- src/Terraria\Terraria.Graphics\TextureManager.cs -+++ src/tModLoader\Terraria.Graphics\TextureManager.cs -@@ -35,7 +35,6 @@ - if (!TextureManager._textures.ContainsKey(name)) - { - Texture2D texture2D = TextureManager.BlankTexture; --#if CLIENT - if (name != "" && name != null) - { - try -@@ -47,7 +46,6 @@ - texture2D = TextureManager.BlankTexture; - } - } --#endif - TextureManager._textures[name] = texture2D; - return texture2D; - } - diff --git a/Patcher/patches/tModLoader/Terraria.IO/Preferences.cs.patch b/Patcher/patches/tModLoader/Terraria.IO/Preferences.cs.patch deleted file mode 100644 index 6a24bd585ff..00000000000 --- a/Patcher/patches/tModLoader/Terraria.IO/Preferences.cs.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- src/Terraria\Terraria.IO\Preferences.cs -+++ src/tModLoader\Terraria.IO\Preferences.cs -@@ -25,11 +25,10 @@ - this.UseBson = useBson; - if (parseAllTypes) - { -- this._serializerSettings = new JsonSerializerSettings -- { -- TypeNameHandling = TypeNameHandling.Auto, -- MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead -- }; -+ JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings(); -+ jsonSerializerSettings.TypeNameHandling = TypeNameHandling.Auto; -+ jsonSerializerSettings.MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead; -+ this._serializerSettings = jsonSerializerSettings; - return; - } - this._serializerSettings = new JsonSerializerSettings(); -@@ -50,8 +49,8 @@ - { - if (!this.UseBson) - { -- string value = File.ReadAllText(this._path); -- this._data = JsonConvert.DeserializeObject>(value, this._serializerSettings); -+ string text = File.ReadAllText(this._path); -+ this._data = JsonConvert.DeserializeObject>(text, this._serializerSettings); - } - else - { - diff --git a/Patcher/patches/tModLoader/Terraria.IO/WorldFile.cs.patch b/Patcher/patches/tModLoader/Terraria.IO/WorldFile.cs.patch deleted file mode 100644 index 79020f33395..00000000000 --- a/Patcher/patches/tModLoader/Terraria.IO/WorldFile.cs.patch +++ /dev/null @@ -1,137 +0,0 @@ ---- src/Terraria\Terraria.IO\WorldFile.cs -+++ src/tModLoader\Terraria.IO\WorldFile.cs -@@ -5,6 +5,7 @@ - using Terraria.DataStructures; - using Terraria.GameContent.Events; - using Terraria.ID; -+using Terraria.ModLoader; - using Terraria.Social; - using Terraria.Utilities; - -@@ -855,7 +856,7 @@ - - private static int SaveFileFormatHeader(BinaryWriter writer) - { -- short num = 419; -+ short num = (short)TileLoader.TileCount(); - short num2 = 10; - writer.Write(Main.curRelease); - Main.WorldFileMetadata.IncrementAndWrite(writer); -@@ -1032,7 +1033,8 @@ - - private static int SaveWorldTiles(BinaryWriter writer) - { -- byte[] array = new byte[13]; -+ TileLoader.WriteTable(writer); -+ byte[] array = new byte[14]; - for (int i = 0; i < Main.maxTilesX; i++) - { - float num = (float)i / (float)Main.maxTilesX; -@@ -1107,8 +1109,9 @@ - if (tile.wall != 0) - { - b2 |= 4; -- array[num2] = tile.wall; -+ array[num2] = (byte)tile.wall; - num2++; -+ WallLoader.WriteType(tile.wall, array, ref num2, ref b3); - if (tile.wallColor() != 0) - { - b3 |= 16; -@@ -1278,7 +1281,7 @@ - writer.Write((short)item.stack); - if (item.stack > 0) - { -- writer.Write(item.netID); -+ ItemLoader.WriteID(item, writer); - writer.Write(item.prefix); - } - } -@@ -1716,6 +1719,9 @@ - - private static void LoadWorldTiles(BinaryReader reader, bool[] importance) - { -+ IDictionary modTiles = new Dictionary(); -+ IDictionary modWalls = new Dictionary(); -+ TileLoader.ReadTable(reader, modTiles, modWalls); - for (int i = 0; i < Main.maxTilesX; i++) - { - float num = (float)i / (float)Main.maxTilesX; -@@ -1755,7 +1761,7 @@ - { - num2 = (int)reader.ReadByte(); - } -- tile.type = (ushort)num2; -+ tile.type = TileLoader.ReadTileType(num2, modTiles); - if (importance[num2]) - { - tile.frameX = reader.ReadInt16(); -@@ -1770,6 +1776,7 @@ - tile.frameX = -1; - tile.frameY = -1; - } -+ num2 = (int)tile.type; - if ((b & 8) == 8) - { - tile.color(reader.ReadByte()); -@@ -1778,6 +1785,7 @@ - if ((b3 & 4) == 4) - { - tile.wall = reader.ReadByte(); -+ WallLoader.ReadType(ref tile.wall, reader, b, modWalls); - if ((b & 16) == 16) - { - tile.wallColor(reader.ReadByte()); -@@ -1915,13 +1923,13 @@ - Item item = new Item(); - if (num5 > 0) - { -- item.netDefaults(reader.ReadInt32()); -+ ItemLoader.ReadID(item, reader); - item.stack = (int)num5; - item.Prefix((int)reader.ReadByte()); - } - else if (num5 < 0) - { -- item.netDefaults(reader.ReadInt32()); -+ ItemLoader.ReadID(item, reader); - item.Prefix((int)reader.ReadByte()); - item.stack = 1; - } -@@ -1932,7 +1940,7 @@ - short num5 = reader.ReadInt16(); - if (num5 > 0) - { -- reader.ReadInt32(); -+ ItemLoader.ReadID(new Item(), reader); - reader.ReadByte(); - } - } -@@ -2111,6 +2119,7 @@ - int num3 = fileIO.ReadInt32(); - int num4 = fileIO.ReadInt32(); - baseStream.Position = (long)array2[1]; -+ TileLoader.ReadTable(fileIO, new Dictionary(), new Dictionary()); - for (int i = 0; i < num4; i++) - { - float num5 = (float)i / (float)Main.maxTilesX; -@@ -2159,7 +2168,8 @@ - } - if ((b3 & 4) == 4) - { -- fileIO.ReadByte(); -+ ushort wall = fileIO.ReadByte(); -+ WallLoader.ReadType(ref wall, fileIO, b2, new Dictionary()); - if ((b2 & 16) == 16) - { - fileIO.ReadByte(); -@@ -2204,7 +2214,7 @@ - int num10 = (int)fileIO.ReadInt16(); - if (num10 > 0) - { -- fileIO.ReadInt32(); -+ ItemLoader.ReadID(new Item(), fileIO); - fileIO.ReadByte(); - } - } - diff --git a/Patcher/patches/tModLoader/Terraria.Initializers/LaunchInitializer.cs.patch b/Patcher/patches/tModLoader/Terraria.Initializers/LaunchInitializer.cs.patch deleted file mode 100644 index c00bdbea611..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Initializers/LaunchInitializer.cs.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- src/Terraria\Terraria.Initializers\LaunchInitializer.cs -+++ src/tModLoader\Terraria.Initializers\LaunchInitializer.cs -@@ -9,11 +9,7 @@ - public static void LoadParameters(Main game) - { - LaunchInitializer.LoadSharedParameters(game); --#if CLIENT - LaunchInitializer.LoadClientParameters(game); --#else -- LaunchInitializer.LoadServerParameters(game); --#endif - } - - private static void LoadSharedParameters(Main game) - diff --git a/Patcher/patches/tModLoader/Terraria.Social.Steam/CoreSocialModule.cs.patch b/Patcher/patches/tModLoader/Terraria.Social.Steam/CoreSocialModule.cs.patch deleted file mode 100644 index 187ae34ec49..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Social.Steam/CoreSocialModule.cs.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- src/Terraria\Terraria.Social.Steam\CoreSocialModule.cs -+++ src/tModLoader\Terraria.Social.Steam\CoreSocialModule.cs -@@ -19,13 +19,11 @@ - public void Initialize() - { - CoreSocialModule._instance = this; --#if CLIENT - if (SteamAPI.RestartAppIfNecessary(new AppId_t(105600u))) - { - Environment.Exit(1); - return; - } --#endif - if (!SteamAPI.Init()) - { - MessageBox.Show("Please launch the game from your Steam client.", "Error"); - diff --git a/Patcher/patches/tModLoader/Terraria.Social.Steam/Lobby.cs.patch b/Patcher/patches/tModLoader/Terraria.Social.Steam/Lobby.cs.patch deleted file mode 100644 index a9d75d1f51d..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Social.Steam/Lobby.cs.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- src/Terraria\Terraria.Social.Steam\Lobby.cs -+++ src/tModLoader\Terraria.Social.Steam\Lobby.cs -@@ -24,9 +24,9 @@ - - public void Create(bool inviteOnly, CallResult.APIDispatchDelegate callResult) - { -- SteamAPICall_t hAPICall = SteamMatchmaking.CreateLobby(inviteOnly ? ELobbyType.k_ELobbyTypePrivate : ELobbyType.k_ELobbyTypeFriendsOnly, 256); -+ SteamAPICall_t steamAPICall_t = SteamMatchmaking.CreateLobby(inviteOnly ? ELobbyType.k_ELobbyTypePrivate : ELobbyType.k_ELobbyTypeFriendsOnly, 256); - this._lobbyCreatedExternalCallback = callResult; -- this._lobbyCreated.Set(hAPICall, null); -+ this._lobbyCreated.Set(steamAPICall_t, null); - this.State = LobbyState.Creating; - } - -@@ -48,8 +48,8 @@ - } - this.State = LobbyState.Connecting; - this._lobbyEnterExternalCallback = callResult; -- SteamAPICall_t hAPICall = SteamMatchmaking.JoinLobby(lobbyId); -- this._lobbyEnter.Set(hAPICall, null); -+ SteamAPICall_t steamAPICall_t = SteamMatchmaking.JoinLobby(lobbyId); -+ this._lobbyEnter.Set(steamAPICall_t, null); - } - - public byte[] GetMessage(int index) -@@ -125,7 +125,7 @@ - } - this.Id = new CSteamID(result.m_ulSteamIDLobby); - this.Owner = SteamMatchmaking.GetLobbyOwner(this.Id); -- this._lobbyEnterExternalCallback(result, failure); -+ this._lobbyEnterExternalCallback.Invoke(result, failure); - } - - private void OnLobbyCreated(LobbyCreated_t result, bool failure) -@@ -144,7 +144,7 @@ - } - this.Id = new CSteamID(result.m_ulSteamIDLobby); - this.Owner = SteamMatchmaking.GetLobbyOwner(this.Id); -- this._lobbyCreatedExternalCallback(result, failure); -+ this._lobbyCreatedExternalCallback.Invoke(result, failure); - } - } - } - diff --git a/Patcher/patches/tModLoader/Terraria.Social.Steam/NetClientSocialModule.cs.patch b/Patcher/patches/tModLoader/Terraria.Social.Steam/NetClientSocialModule.cs.patch deleted file mode 100644 index ddb6c3bad6b..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Social.Steam/NetClientSocialModule.cs.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- src/Terraria\Terraria.Social.Steam\NetClientSocialModule.cs -+++ src/tModLoader\Terraria.Social.Steam\NetClientSocialModule.cs -@@ -33,10 +33,10 @@ - - private void CheckParameters() - { -- ulong ulSteamID; -- if (Program.LaunchParameters.ContainsKey("+connect_lobby") && ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out ulSteamID)) -- { -- CSteamID lobbySteamId = new CSteamID(ulSteamID); -+ ulong num; -+ if (Program.LaunchParameters.ContainsKey("+connect_lobby") && ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out num)) -+ { -+ CSteamID lobbySteamId = new CSteamID(num); - if (lobbySteamId.IsValid()) - { - Main.OpenPlayerSelect(delegate(PlayerFileData playerData) - diff --git a/Patcher/patches/tModLoader/Terraria.Social/SocialAPI.cs.patch b/Patcher/patches/tModLoader/Terraria.Social/SocialAPI.cs.patch deleted file mode 100644 index 05f74bf261c..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Social/SocialAPI.cs.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- src/Terraria\Terraria.Social\SocialAPI.cs -+++ src/tModLoader\Terraria.Social\SocialAPI.cs -@@ -27,14 +27,7 @@ - if (!mode.HasValue) - { - mode = new SocialMode?(SocialMode.None); --#if CLIENT - mode = new SocialMode?(SocialMode.Steam); --#else -- if (Program.LaunchParameters.ContainsKey("-steam")) -- { -- mode = new SocialMode?(SocialMode.Steam); -- } --#endif - } - SocialAPI._mode = mode.Value; - SocialAPI._modules = new List(); -@@ -77,11 +70,7 @@ - SocialAPI.Friends = SocialAPI.LoadModule(); - SocialAPI.Achievements = SocialAPI.LoadModule(); - SocialAPI.Cloud = SocialAPI.LoadModule(); --#if CLIENT - SocialAPI.Network = SocialAPI.LoadModule(); --#else -- SocialAPI.Network = SocialAPI.LoadModule(); --#endif - } - } - } - diff --git a/Patcher/patches/tModLoader/Terraria.Utilities/CrashDump.cs.patch b/Patcher/patches/tModLoader/Terraria.Utilities/CrashDump.cs.patch deleted file mode 100644 index 20d40ace079..00000000000 --- a/Patcher/patches/tModLoader/Terraria.Utilities/CrashDump.cs.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- src/Terraria\Terraria.Utilities\CrashDump.cs -+++ src/tModLoader\Terraria.Utilities\CrashDump.cs -@@ -34,11 +34,7 @@ - DateTime dateTime = DateTime.Now.ToLocalTime(); - string path = string.Concat(new string[] - { --#if CLIENT -- "Terraria ", --#else -- "TerrariaServer", --#endif -+ "Terraria ", - Main.versionNumber, - " ", - dateTime.Year.ToString("D4"), -@@ -62,11 +58,7 @@ - DateTime dateTime = DateTime.Now.ToLocalTime(); - string path = string.Concat(new string[] - { --#if CLIENT -- "DMP-FULL Terraria ", --#else -- "DMP-FULL TerrariaServer", --#endif -+ "DMP-FULL Terraria ", - Main.versionNumber, - " ", - dateTime.Year.ToString("D4"), - diff --git a/Patcher/patches/tModLoader/Terraria/Lang.cs.patch b/Patcher/patches/tModLoader/Terraria/Lang.cs.patch deleted file mode 100644 index b2e521df7ec..00000000000 --- a/Patcher/patches/tModLoader/Terraria/Lang.cs.patch +++ /dev/null @@ -1,107 +0,0 @@ ---- src/Terraria\Terraria\Lang.cs -+++ src/tModLoader\Terraria\Lang.cs -@@ -1,8 +1,7 @@ - using System; -+using Terraria.Map; -+using Terraria.ModLoader; - --#if CLIENT --using Terraria.Map; --#endif - namespace Terraria - { - public class Lang -@@ -17,7 +16,7 @@ - public static string[] dt = new string[4]; - public static string[] chestType = new string[52]; - public static string[] dresserType = new string[28]; -- public static string[] mapLegend; -+ public static MapLegend mapLegend; - public static string[] prefix = new string[84]; - public static string the; - -@@ -32676,10 +32675,9 @@ - Main.buffTip[78] = "Melee attacks cause confetti to appear"; - Main.buffName[79] = "Weapon Imbue: Poison"; - Main.buffTip[79] = "Melee attacks poison enemies"; --#if CLIENT - if (Lang.mapLegend == null) - { -- Lang.mapLegend = new string[MapHelper.LookupCount()]; -+ Lang.mapLegend = new MapLegend(MapHelper.LookupCount()); - } - Lang.mapLegend[MapHelper.TileToLookup(4, 0)] = "Torch"; - Lang.mapLegend[MapHelper.TileToLookup(4, 1)] = "Torch"; -@@ -32931,7 +32929,6 @@ - Lang.mapLegend[j] = string.Empty; - } - } --#endif - Lang.chestType[0] = "Chest"; - Lang.chestType[1] = "Gold Chest"; - Lang.chestType[2] = "Locked Gold Chest"; -@@ -33618,7 +33615,6 @@ - Main.buffTip[78] = "Nahkampfangriffe verursachen Konfetti zu erscheinen"; - Main.buffName[79] = "Waffe verleihen: Gift"; - Main.buffTip[79] = "Nahkampfangriffe Gift Feinde"; --#if CLIENT - Lang.mapLegend[MapHelper.TileToLookup(13, 0)] = "Flasche"; - Lang.mapLegend[MapHelper.TileToLookup(14, 0)] = "Tabelle"; - Lang.mapLegend[MapHelper.TileToLookup(15, 0)] = "Stuhl"; -@@ -33635,7 +33631,6 @@ - Lang.mapLegend[MapHelper.TileToLookup(114, 0)] = "Tueftler-Werkstatt"; - Lang.mapLegend[MapHelper.TileToLookup(133, 0)] = "Adamantitschmiede"; - Lang.mapLegend[MapHelper.TileToLookup(134, 0)] = "Mithrilamboss"; --#endif - Lang.prefix[1] = "Gross"; - Lang.prefix[2] = "Massiv"; - Lang.prefix[3] = "Gefährlich"; -@@ -34242,7 +34237,6 @@ - Main.buffTip[78] = "Attacchi corpo a corpo causano a comparire coriandoli"; - Main.buffName[79] = "Arma Imbue: Poison"; - Main.buffTip[79] = "Mischia attacca nemici veleno"; --#if CLIENT - Lang.mapLegend[MapHelper.TileToLookup(13, 0)] = "Bottiglia"; - Lang.mapLegend[MapHelper.TileToLookup(14, 0)] = "Tavolo"; - Lang.mapLegend[MapHelper.TileToLookup(15, 0)] = "Sedia"; -@@ -34259,7 +34253,6 @@ - Lang.mapLegend[MapHelper.TileToLookup(114, 0)] = "Laboratorio dell'inventore"; - Lang.mapLegend[MapHelper.TileToLookup(133, 0)] = "Fornace di adamantio"; - Lang.mapLegend[MapHelper.TileToLookup(134, 0)] = "Incudine di mitrilio"; --#endif - Lang.prefix[1] = "Grande"; - Lang.prefix[2] = "Massiccio"; - Lang.prefix[3] = "Pericoloso"; -@@ -34866,7 +34859,6 @@ - Main.buffTip[78] = "Les attaques de mêlée causent des confettis à comparaître"; - Main.buffName[79] = "Arme Imbue: Poison"; - Main.buffTip[79] = "Attaques de mêlée des ennemis de poison"; --#if CLIENT - Lang.mapLegend[MapHelper.TileToLookup(13, 0)] = "Bouteille"; - Lang.mapLegend[MapHelper.TileToLookup(14, 0)] = "Table"; - Lang.mapLegend[MapHelper.TileToLookup(15, 0)] = "Président"; -@@ -34883,7 +34875,6 @@ - Lang.mapLegend[MapHelper.TileToLookup(114, 0)] = "Atelier du bricoleur"; - Lang.mapLegend[MapHelper.TileToLookup(133, 0)] = "Forge en adamantine"; - Lang.mapLegend[MapHelper.TileToLookup(134, 0)] = "Enclume en mythril"; --#endif - Lang.prefix[1] = "Grand"; - Lang.prefix[2] = "Massif"; - Lang.prefix[3] = "Dangereuses"; -@@ -35490,7 +35481,6 @@ - Main.buffTip[78] = "Ataques cuerpo a cuerpo infligen confetti que aparezca"; - Main.buffName[79] = "imbuir armas: tóxico"; - Main.buffTip[79] = "Cuerpo a cuerpo ataca a los enemigos de veneno"; --#if CLIENT - Lang.mapLegend[MapHelper.TileToLookup(13, 0)] = "Botella"; - Lang.mapLegend[MapHelper.TileToLookup(14, 0)] = "Mesa"; - Lang.mapLegend[MapHelper.TileToLookup(15, 0)] = "Silla"; -@@ -35507,7 +35497,6 @@ - Lang.mapLegend[MapHelper.TileToLookup(114, 0)] = "Taller del reparador"; - Lang.mapLegend[MapHelper.TileToLookup(133, 0)] = "Forja de adamantita"; - Lang.mapLegend[MapHelper.TileToLookup(134, 0)] = "Yunque de mithril"; --#endif - Lang.prefix[1] = "Grande"; - Lang.prefix[2] = "Masivo"; - Lang.prefix[3] = "Peligroso"; - diff --git a/Patcher/patches/tModLoader/Terraria/Minecart.cs.patch b/Patcher/patches/tModLoader/Terraria/Minecart.cs.patch deleted file mode 100644 index 91b83d90a5f..00000000000 --- a/Patcher/patches/tModLoader/Terraria/Minecart.cs.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- src/Terraria\Terraria\Minecart.cs -+++ src/tModLoader\Terraria\Minecart.cs -@@ -55,12 +55,10 @@ - - public static void Initialize() - { --#if CLIENT - if ((float)Main.minecartMountTexture.Width != 50f) - { - throw new Exception("Be sure to update Minecart.textureWidth to match the actual texture size of " + Main.minecartMountTexture.Width + "."); - } --#endif - Minecart._rightSideConnection = new int[36]; - Minecart._leftSideConnection = new int[36]; - Minecart._trackType = new int[36]; - diff --git a/Patcher/patches/tModLoader/Terraria/Mount.cs.patch b/Patcher/patches/tModLoader/Terraria/Mount.cs.patch deleted file mode 100644 index e65a2f45592..00000000000 --- a/Patcher/patches/tModLoader/Terraria/Mount.cs.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- src/Terraria\Terraria\Mount.cs -+++ src/tModLoader\Terraria\Mount.cs -@@ -946,20 +946,18 @@ - mountData.textureHeight = mountData.frontTexture.Height; - } - Mount.drillTextureSize = new Vector2(80f, 80f); --#if CLIENT - Vector2 value = new Vector2((float)mountData.textureWidth, (float)(mountData.textureHeight / mountData.totalFrames)); - if (Mount.drillTextureSize != value) - { - throw new Exception(string.Concat(new object[] -- { -- "Be sure to update the Drill texture origin to match the actual texture size of ", -- mountData.textureWidth, -- ", ", -- mountData.textureHeight, -- "." -- })); -- } --#endif -+ { -+ "Be sure to update the Drill texture origin to match the actual texture size of ", -+ mountData.textureWidth, -+ ", ", -+ mountData.textureHeight, -+ "." -+ })); -+ } - mountData = new Mount.MountData(); - Mount.mounts[9] = mountData; - mountData.spawnDust = 152; -@@ -1028,20 +1026,18 @@ - Mount.scutlixEyePositions[8] = new Vector2(70f, 34f); - Mount.scutlixEyePositions[9] = new Vector2(76f, 34f); - Mount.scutlixTextureSize = new Vector2(45f, 54f); --#if CLIENT - Vector2 value2 = new Vector2((float)(mountData.textureWidth / 2), (float)(mountData.textureHeight / mountData.totalFrames)); - if (Mount.scutlixTextureSize != value2) - { - throw new Exception(string.Concat(new object[] -- { -- "Be sure to update the Scutlix texture origin to match the actual texture size of ", -- mountData.textureWidth, -- ", ", -- mountData.textureHeight, -- "." -- })); -- } --#endif -+ { -+ "Be sure to update the Scutlix texture origin to match the actual texture size of ", -+ mountData.textureWidth, -+ ", ", -+ mountData.textureHeight, -+ "." -+ })); -+ } - for (int num5 = 0; num5 < Mount.scutlixEyePositions.Length; num5++) - { - Mount.scutlixEyePositions[num5] -= Mount.scutlixTextureSize; - diff --git a/Patcher/patches/tModLoader/Terraria/NetMessage.cs.patch b/Patcher/patches/tModLoader/Terraria/NetMessage.cs.patch deleted file mode 100644 index 123f540f668..00000000000 --- a/Patcher/patches/tModLoader/Terraria/NetMessage.cs.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- src/Terraria\Terraria\NetMessage.cs -+++ src/tModLoader\Terraria\NetMessage.cs -@@ -1385,7 +1385,7 @@ - { - memoryStream.Position = 0L; - MemoryStream memoryStream2 = new MemoryStream(); -- using (DeflateStream deflateStream = new DeflateStream(memoryStream2, CompressionMode.Compress, true)) -+ using (DeflateStream deflateStream = new DeflateStream(memoryStream2, 0, true)) - { - memoryStream.CopyTo(deflateStream); - deflateStream.Flush(); -@@ -1557,7 +1557,7 @@ - if (tile2.wall != 0) - { - b |= 4; -- array4[num5] = tile2.wall; -+ array4[num5] = (byte)tile2.wall; - num5++; - if (tile2.wallColor() != 0) - { -@@ -1959,12 +1959,6 @@ - } - catch - { --#if SERVER -- if (num < NetMessage.buffer.Length - 100) -- { -- Console.WriteLine("Error on message " + NetMessage.buffer[num + 2]); -- } --#endif - i = 0; - num = 0; - } - diff --git a/Patcher/patches/tModLoader/Terraria/Netplay.cs.patch b/Patcher/patches/tModLoader/Terraria/Netplay.cs.patch deleted file mode 100644 index 23509f41ccf..00000000000 --- a/Patcher/patches/tModLoader/Terraria/Netplay.cs.patch +++ /dev/null @@ -1,79 +0,0 @@ ---- src/Terraria\Terraria\Netplay.cs -+++ src/tModLoader\Terraria\Netplay.cs -@@ -8,9 +8,6 @@ - using Terraria.Net.Sockets; - using Terraria.Social; - --#if SERVER --using NATUPNPLib; --#endif - namespace Terraria - { - public class Netplay -@@ -31,10 +28,6 @@ - public static bool disconnect = false; - public static bool spamCheck = false; - public static bool anyClients = false; -- #if SERVER -- public static UPnPNAT upnpnat = (UPnPNAT)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1"))); -- public static IStaticPortMappingCollection mappings = Netplay.upnpnat.StaticPortMappingCollection; --#endif - public static string portForwardIP; - public static int portForwardPort; - public static bool portForwardOpen; -@@ -45,33 +38,10 @@ - { - Netplay.portForwardIP = Netplay.GetLocalIPAddress(); - Netplay.portForwardPort = Netplay.ListenPort; --#if SERVER -- if (Netplay.mappings != null) -- { -- foreach (IStaticPortMapping staticPortMapping in Netplay.mappings) -- { -- if (staticPortMapping.InternalPort == Netplay.portForwardPort && staticPortMapping.InternalClient == Netplay.portForwardIP && staticPortMapping.Protocol == "TCP") -- { -- Netplay.portForwardOpen = true; -- } -- } -- if (!Netplay.portForwardOpen) -- { -- Netplay.mappings.Add(Netplay.portForwardPort, "TCP", Netplay.portForwardPort, Netplay.portForwardIP, true, "Terraria Server"); -- Netplay.portForwardOpen = true; -- } -- } --#endif - } - - public static void closePort() - { --#if SERVER -- if (Netplay.portForwardOpen) -- { -- Netplay.mappings.Remove(Netplay.portForwardPort, "TCP"); -- } --#endif - } - - public static string GetLocalIPAddress() -@@ -791,20 +761,8 @@ - - public static void Initialize() - { --#if CLIENT - NetMessage.buffer[256] = new MessageBuffer(); - NetMessage.buffer[256].whoAmI = 256; --#else -- for (int i = 0; i < 257; i++) -- { -- if (i < 256) -- { -- Netplay.Clients[i] = new RemoteClient(); -- } -- NetMessage.buffer[i] = new MessageBuffer(); -- NetMessage.buffer[i].whoAmI = i; -- } --#endif - } - - public static int GetSectionX(int x) - diff --git a/Patcher/patches/tModLoader/Terraria/Program.cs.patch b/Patcher/patches/tModLoader/Terraria/Program.cs.patch deleted file mode 100644 index 4be2f423828..00000000000 --- a/Patcher/patches/tModLoader/Terraria/Program.cs.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- src/Terraria\Terraria\Program.cs -+++ src/tModLoader\Terraria\Program.cs -@@ -1,22 +1,15 @@ - using System; - using System.Collections.Generic; - using System.IO; -+using System.Windows.Forms; - using Terraria.Initializers; - using Terraria.Social; - --#if CLIENT --using System.Windows.Forms; --#endif - namespace Terraria - { - public static class Program - { -- #if CLIENT - public const bool IsServer = false; -- --#else -- public const bool IsServer = true; -- #endif - public static Dictionary LaunchParameters = new Dictionary(); - - public static void LaunchGame(string[] args) -@@ -28,11 +21,7 @@ - { - SocialAPI.Initialize(null); - LaunchInitializer.LoadParameters(main); --#if CLIENT - main.Run(); --#else -- main.DedServ(); --#endif - } - catch (Exception e) - { -@@ -51,14 +40,7 @@ - streamWriter.WriteLine(e); - streamWriter.WriteLine(""); - } --#if CLIENT - MessageBox.Show(e.ToString(), "Terraria: Error"); --#else -- Console.WriteLine("Server crash: " + DateTime.Now); -- Console.WriteLine(e); -- Console.WriteLine(""); -- Console.WriteLine("Please send crashlog.txt to support@terraria.org"); --#endif - } - catch - { - diff --git a/Patcher/patches/tModLoader/Terraria/WindowsLaunch.cs.patch b/Patcher/patches/tModLoader/Terraria/WindowsLaunch.cs.patch deleted file mode 100644 index 5e01137b712..00000000000 --- a/Patcher/patches/tModLoader/Terraria/WindowsLaunch.cs.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- src/Terraria\Terraria\WindowsLaunch.cs -+++ src/tModLoader\Terraria\WindowsLaunch.cs -@@ -69,10 +69,6 @@ - } - return result; - }; --#if SERVER -- WindowsLaunch._handleRoutine = new WindowsLaunch.HandlerRoutine(WindowsLaunch.ConsoleCtrlCheck); -- WindowsLaunch.SetConsoleCtrlHandler(WindowsLaunch._handleRoutine, true); --#endif - Program.LaunchGame(args); - } - } - diff --git a/Patcher/setup/bin/setup.pdb b/Patcher/setup/bin/setup.pdb deleted file mode 100644 index aba4ad72207..00000000000 Binary files a/Patcher/setup/bin/setup.pdb and /dev/null differ diff --git a/README.md b/README.md index 8e82f8aaa17..c0b2c77231e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Note that this repository will usually be ahead of the current released version. ### Getting the tModLoader code -If you want to contribute to this project, you'll have to download the code for tModLoader, including all the changes made to the Terraria source. This requires you to have purchased your own Terraria.exe first. In order to do this, first clone the repository, then open the Patcher folder. Run the setup.bat file. If setup.bat doesn't work, you may have to unblock the files in the Patcher folder. Once tModLoader Dev Setup is open, just click on the Setup button and select the location of your vanilla Terraria.exe. **Warning:** decompiling will probably freeze your computer for a couple of hours. So you'll need to find something to do in real life until that's done. +If you want to contribute to this project, you'll have to download the code for tModLoader, including all the changes made to the Terraria source. This requires you to have purchased your own Terraria.exe first. In order to do get the tModLoader code, first clone the repository, then run the setup.bat file. If setup.bat doesn't work, you may have to unblock the files in the repository. Once tModLoader Dev Setup is open, just click on the Setup button and select the location of your vanilla Terraria.exe. **Warning:** decompiling will probably freeze your computer for a couple of hours. So you'll need to find something to do in real life until that's done. When that's all done, you should have the tModLoader source in the src folder. Open the solutions folder then open the tModLoader solution. diff --git a/Terraria.ModLoader.UI/UIBuildMod.cs b/Terraria.ModLoader.UI/UIBuildMod.cs deleted file mode 100644 index a231a93d3a2..00000000000 --- a/Terraria.ModLoader.UI/UIBuildMod.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.IO; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIBuildMod : UIState -{ - private UILoadProgress loadProgress; - public override void OnInitialize() - { - loadProgress = new UILoadProgress(); - loadProgress.Width.Set(0f, 0.8f); - loadProgress.MaxWidth.Set(600f, 0f); - loadProgress.Height.Set(150f, 0f); - loadProgress.HAlign = 0.5f; - loadProgress.VAlign = 0.5f; - loadProgress.Top.Set(10f, 0f); - base.Append(loadProgress); - } - - internal void SetProgress(int num, int max) - { - loadProgress.SetProgress((float)num / (float)max); - } - - internal void SetReading() - { - loadProgress.SetText("Reading Properties: " + Path.GetFileName(ModLoader.modToBuild)); - } - - internal void SetCompiling() - { - loadProgress.SetText("Compiling " + Path.GetFileName(ModLoader.modToBuild) + "..."); - } - - internal void SetBuildText() - { - loadProgress.SetText("Building " + Path.GetFileName(ModLoader.modToBuild) + "..."); - } -}} diff --git a/Terraria.ModLoader.UI/UIColorTextPanel.cs b/Terraria.ModLoader.UI/UIColorTextPanel.cs deleted file mode 100644 index 01ad48dec61..00000000000 --- a/Terraria.ModLoader.UI/UIColorTextPanel.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria.GameContent.UI.Elements; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIColorTextPanel : UIPanel -{ - private string _text = ""; - private Color _color; - private float _textScale = 1f; - private Vector2 _textSize = Vector2.Zero; - private bool _isLarge; - public UIColorTextPanel(string text, Color color, float textScale = 1f, bool large = false) - { - this.SetText(text, textScale, large); - this.SetColor(color); - } - public override void Recalculate() - { - this.SetText(this._text, this._textScale, this._isLarge); - base.Recalculate(); - } - public void SetText(string text, float textScale, bool large) - { - SpriteFont spriteFont = large ? Main.fontDeathText : Main.fontMouseText; - Vector2 textSize = new Vector2(spriteFont.MeasureString(text).X, large ? 32f : 16f) * textScale; - this._text = text; - this._textScale = textScale; - this._textSize = textSize; - this._isLarge = large; - this.MinWidth.Set(textSize.X + this.PaddingLeft + this.PaddingRight, 0f); - this.MinHeight.Set(textSize.Y + this.PaddingTop + this.PaddingBottom, 0f); - } - public void SetColor(Color color) - { - this._color = color; - } - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - CalculatedStyle innerDimensions = base.GetInnerDimensions(); - Vector2 pos = innerDimensions.Position(); - if (this._isLarge) - { - pos.Y -= 10f * this._textScale; - } - else - { - pos.Y -= 2f * this._textScale; - } - pos.X += (innerDimensions.Width - this._textSize.X) * 0.5f; - if (this._isLarge) - { - Utils.DrawBorderStringBig(spriteBatch, this._text, pos, this._color, this._textScale, 0f, 0f, -1); - return; - } - Utils.DrawBorderString(spriteBatch, this._text, pos, this._color, this._textScale, 0f, 0f, -1); - } -}} diff --git a/Terraria.ModLoader.UI/UIErrorMessage.cs b/Terraria.ModLoader.UI/UIErrorMessage.cs deleted file mode 100644 index f28eb382927..00000000000 --- a/Terraria.ModLoader.UI/UIErrorMessage.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Diagnostics; -using Microsoft.Xna.Framework; -using Terraria.GameContent.UI.Elements; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIErrorMessage : UIState -{ - private UIMessageBox message = new UIMessageBox(""); - private int gotoMenu = 0; - private string file; - public override void OnInitialize() - { - UIElement area = new UIElement(); - area.Width.Set(0f, 0.8f); - area.Top.Set(200f, 0f); - area.Height.Set(-240f, 1f); - area.HAlign = 0.5f; - - message.Width.Set(0f, 1f); - message.Height.Set(0f, 0.8f); - message.HAlign = 0.5f; - area.Append(message); - UITextPanel button = new UITextPanel("Continue", 0.7f, true); - button.Width.Set(-10f, 0.5f); - button.Height.Set(50f, 0f); - button.VAlign = 1f; - button.Top.Set(-30f, 0f); - button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button.OnClick += new UIElement.MouseEvent(ContinueClick); - area.Append(button); - UITextPanel button2 = new UITextPanel("Open Logs", 0.7f, true); - button2.CopyStyle(button); - button2.HAlign = 1f; - button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button2.OnClick += new UIElement.MouseEvent(OpenFile); - area.Append(button2); - - base.Append(area); - } - - internal void SetMessage(string text) - { - message.SetText(text); - } - - internal void SetGotoMenu(int gotoMenu) - { - this.gotoMenu = gotoMenu; - } - - internal void SetFile(string file) - { - this.file = file; - } - - private static void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171); - } - - private static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) - { - ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f; - } - - private void ContinueClick(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - Main.menuMode = this.gotoMenu; - } - - private void OpenFile(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - Process.Start(file); - } -}} diff --git a/Terraria.ModLoader.UI/UILoadMods.cs b/Terraria.ModLoader.UI/UILoadMods.cs deleted file mode 100644 index 61a1f09e1f1..00000000000 --- a/Terraria.ModLoader.UI/UILoadMods.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UILoadMods : UIState -{ - private UILoadProgress loadProgress; - public override void OnInitialize() - { - loadProgress = new UILoadProgress(); - loadProgress.Width.Set(0f, 0.8f); - loadProgress.MaxWidth.Set(600f, 0f); - loadProgress.Height.Set(150f, 0f); - loadProgress.HAlign = 0.5f; - loadProgress.VAlign = 0.5f; - loadProgress.Top.Set(10f, 0f); - base.Append(loadProgress); - } - - internal void SetProgressFinding() - { - loadProgress.SetText("Finding Mods..."); - loadProgress.SetProgress(0f); - } - - internal void SetProgressReading(string mod, int num, int max) - { - loadProgress.SetText("Reading: " + mod); - loadProgress.SetProgress((float)num / (float)max); - } - - internal void SetProgressInit(string mod, int num, int max) - { - loadProgress.SetText("Initializing: " + mod); - loadProgress.SetProgress((float)num / (float)max); - } - - internal void SetProgressSetup(float progress) - { - loadProgress.SetText("Setting up..."); - loadProgress.SetProgress(progress); - } - - internal void SetProgressLoad(string mod, int num, int max) - { - loadProgress.SetText("Loading Mod: " + mod); - loadProgress.SetProgress((float)num / (float)max); - } - - internal void SetProgressRecipes() - { - loadProgress.SetText("Adding Recipes..."); - loadProgress.SetProgress(0f); - } -}} diff --git a/Terraria.ModLoader.UI/UILoadProgress.cs b/Terraria.ModLoader.UI/UILoadProgress.cs deleted file mode 100644 index 244bef25066..00000000000 --- a/Terraria.ModLoader.UI/UILoadProgress.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria.GameContent.UI.Elements; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UILoadProgress : UIPanel -{ - private UIText text; - private float progress; - public UILoadProgress() - { - text = new UIText("", 0.75f, true); - text.Top.Set(20f, 0f); - text.HAlign = 0.5f; - base.Append(text); - progress = 0f; - } - - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - CalculatedStyle space = GetInnerDimensions(); - spriteBatch.Draw(Main.magicPixel, new Rectangle((int)space.X + 10, (int)space.Y + (int)space.Height / 2 + 20, (int)space.Width - 20, 10), new Rectangle(0, 0, 1, 1), new Color(0, 0, 70)); - spriteBatch.Draw(Main.magicPixel, new Rectangle((int)space.X + 10, (int)space.Y + (int)space.Height / 2 + 20, (int)((space.Width - 20) * progress), 10), new Rectangle(0, 0, 1, 1), new Color(200, 200, 70)); - } - - internal void SetText(string text) - { - this.text.SetText(text, 0.75f, true); - } - - internal void SetProgress(float progress) - { - this.progress = progress; - } -}} diff --git a/Terraria.ModLoader.UI/UIMessageBox.cs b/Terraria.ModLoader.UI/UIMessageBox.cs deleted file mode 100644 index 4cc643291e1..00000000000 --- a/Terraria.ModLoader.UI/UIMessageBox.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria.GameContent.UI.Elements; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIMessageBox : UIPanel -{ - private string text; - public UIMessageBox(string text) - { - this.text = text; - } - - internal void SetText(string text) - { - this.text = text; - } - - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - CalculatedStyle space = GetInnerDimensions(); - SpriteFont font = Main.fontMouseText; - float position = 0f; - float textHeight = font.MeasureString("A").Y; - string[] lines = text.Split('\n'); - foreach (string line in lines) - { - string drawString = line; - bool flag = false; - if (drawString.Length == 0) - { - position += textHeight; - } - while (drawString.Length > 0) - { - string remainder = ""; - while (font.MeasureString(drawString).X > space.Width) - { - remainder = drawString[drawString.Length - 1] + remainder; - drawString = drawString.Substring(0, drawString.Length - 1); - } - if (position + textHeight > space.Height) - { - flag = true; - break; - } - Utils.DrawBorderString(spriteBatch, drawString, new Vector2(space.X, space.Y + position), Color.White, 1f); - position += textHeight; - drawString = remainder; - } - if (flag) - { - break; - } - } - } -}} diff --git a/Terraria.ModLoader.UI/UIModItem.cs b/Terraria.ModLoader.UI/UIModItem.cs deleted file mode 100644 index 9c7ae74c5c7..00000000000 --- a/Terraria.ModLoader.UI/UIModItem.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.IO; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria.GameContent.UI.Elements; -using Terraria.Graphics; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIModItem : UIPanel -{ - private string mod; - private Texture2D dividerTexture; - private Texture2D innerPanelTexture; - private UIText modName; - internal bool enabled; - public UIModItem(string mod) - { - this.mod = mod; - this.BorderColor = new Color(89, 116, 213) * 0.7f; - this.dividerTexture = TextureManager.Load("Images/UI/Divider"); - this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); - this.Height.Set(90f, 0f); - this.Width.Set(0f, 1f); - base.SetPadding(6f); - base.OnClick += new UIElement.MouseEvent(this.ToggleEnabled); - BuildProperties properties = ModLoader.LoadBuildProperties(mod); - string text = properties.displayName.Length > 0 ? properties.displayName : Path.GetFileNameWithoutExtension(mod); - if(properties.version.Length > 0) - { - text += " " + properties.version; - } - if(properties.author.Length > 0) - { - text += " - by " + properties.author; - } - this.modName = new UIText(text, 1f, false); - this.modName.Left.Set(10f, 0f); - this.modName.Top.Set(5f, 0f); - base.Append(this.modName); - this.enabled = ModLoader.IsEnabled(mod); - } - - private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width) - { - spriteBatch.Draw(this.innerPanelTexture, position, new Rectangle?(new Rectangle(0, 0, 8, this.innerPanelTexture.Height)), Color.White); - spriteBatch.Draw(this.innerPanelTexture, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this.innerPanelTexture.Height)), Color.White, 0f, Vector2.Zero, new Vector2((width - 16f) / 8f, 1f), SpriteEffects.None, 0f); - spriteBatch.Draw(this.innerPanelTexture, new Vector2(position.X + width - 8f, position.Y), new Rectangle?(new Rectangle(16, 0, 8, this.innerPanelTexture.Height)), Color.White); - } - - private void DrawEnabledText(SpriteBatch spriteBatch, Vector2 drawPos) - { - string text = this.enabled ? "Enabled" : "Disabled"; - Color color = this.enabled ? Color.Green : Color.Red; - Utils.DrawBorderString(spriteBatch, text, drawPos, color, 1f, 0f, 0f, -1); - } - - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - CalculatedStyle innerDimensions = base.GetInnerDimensions(); - Vector2 drawPos = new Vector2(innerDimensions.X + 5f, innerDimensions.Y + 30f); - spriteBatch.Draw(this.dividerTexture, drawPos, null, Color.White, 0f, Vector2.Zero, new Vector2((innerDimensions.Width - 10f) / 8f, 1f), SpriteEffects.None, 0f); - drawPos = new Vector2(innerDimensions.X + 10f, innerDimensions.Y + 45f); - this.DrawPanel(spriteBatch, drawPos, 100f); - this.DrawEnabledText(spriteBatch, drawPos + new Vector2(15f, 5f)); - if(this.enabled != ModLoader.ModLoaded(mod)) - { - drawPos += new Vector2(120f, 5f); - Utils.DrawBorderString(spriteBatch, "Reload Required", drawPos, Color.White, 1f, 0f, 0f, -1); - } - string text = this.enabled ? "Click to Disable" : "Click to Enable"; - drawPos = new Vector2(innerDimensions.X + innerDimensions.Width - 150f, innerDimensions.Y + 50f); - Utils.DrawBorderString(spriteBatch, text, drawPos, Color.White, 1f, 0f, 0f, -1); - } - - public override void MouseOver(UIMouseEvent evt) - { - base.MouseOver(evt); - this.BackgroundColor = new Color(73, 94, 171); - this.BorderColor = new Color(89, 116, 213); - } - - public override void MouseOut(UIMouseEvent evt) - { - base.MouseOut(evt); - this.BackgroundColor = new Color(63, 82, 151) * 0.7f; - this.BorderColor = new Color(89, 116, 213) * 0.7f; - } - - internal void ToggleEnabled(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - this.enabled = !this.enabled; - ModLoader.SetModActive(this.mod, this.enabled); - } -}} diff --git a/Terraria.ModLoader.UI/UIModSourceItem.cs b/Terraria.ModLoader.UI/UIModSourceItem.cs deleted file mode 100644 index 235a0b997d3..00000000000 --- a/Terraria.ModLoader.UI/UIModSourceItem.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.IO; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria.GameContent.UI.Elements; -using Terraria.Graphics; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIModSourceItem : UIPanel -{ - private string mod; - private Texture2D dividerTexture; - private UIText modName; - public UIModSourceItem(string mod) - { - this.mod = mod; - this.BorderColor = new Color(89, 116, 213) * 0.7f; - this.dividerTexture = TextureManager.Load("Images/UI/Divider"); - this.Height.Set(90f, 0f); - this.Width.Set(0f, 1f); - base.SetPadding(6f); - this.modName = new UIText(Path.GetFileName(mod), 1f, false); - this.modName.Left.Set(10f, 0f); - this.modName.Top.Set(5f, 0f); - base.Append(this.modName); - UITextPanel button = new UITextPanel("Build", 1f, false); - button.Width.Set(100f, 0f); - button.Height.Set(30f, 0f); - button.Left.Set(10f, 0f); - button.Top.Set(40f, 0f); - button.PaddingTop -= 2f; - button.PaddingBottom -= 2f; - button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button.OnClick += new UIElement.MouseEvent(this.BuildMod); - base.Append(button); - UITextPanel button2 = new UITextPanel("Build + Reload", 1f, false); - button2.CopyStyle(button); - button2.Width.Set(200f, 0f); - button2.Left.Set(150f, 0f); - button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button2.OnClick += new UIElement.MouseEvent(this.BuildAndReload); - base.Append(button2); - base.OnDoubleClick += new UIElement.MouseEvent(this.BuildAndReload); - } - - protected override void DrawSelf(SpriteBatch spriteBatch) - { - base.DrawSelf(spriteBatch); - CalculatedStyle innerDimensions = base.GetInnerDimensions(); - Vector2 drawPos = new Vector2(innerDimensions.X + 5f, innerDimensions.Y + 30f); - spriteBatch.Draw(this.dividerTexture, drawPos, null, Color.White, 0f, Vector2.Zero, new Vector2((innerDimensions.Width - 10f) / 8f, 1f), SpriteEffects.None, 0f); - } - - public override void MouseOver(UIMouseEvent evt) - { - base.MouseOver(evt); - this.BackgroundColor = new Color(73, 94, 171); - this.BorderColor = new Color(89, 116, 213); - } - - public override void MouseOut(UIMouseEvent evt) - { - base.MouseOut(evt); - this.BackgroundColor = new Color(63, 82, 151) * 0.7f; - this.BorderColor = new Color(89, 116, 213) * 0.7f; - } - - private static void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171); - } - - private static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) - { - ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f; - } - - private void BuildMod(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - ModLoader.modToBuild = this.mod; - ModLoader.reloadAfterBuild = false; - ModLoader.buildAll = false; - Main.menuMode = Interface.buildModID; - } - - private void BuildAndReload(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - ModLoader.modToBuild = this.mod; - ModLoader.reloadAfterBuild = true; - ModLoader.buildAll = false; - Main.menuMode = Interface.buildModID; - } -}} diff --git a/Terraria.ModLoader.UI/UIModSources.cs b/Terraria.ModLoader.UI/UIModSources.cs deleted file mode 100644 index 0dd2770cec1..00000000000 --- a/Terraria.ModLoader.UI/UIModSources.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using Microsoft.Xna.Framework; -using Terraria.GameContent.UI.Elements; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIModSources : UIState -{ - private UIList modList; - public override void OnInitialize() - { - UIElement uIElement = new UIElement(); - uIElement.Width.Set(0f, 0.8f); - uIElement.MaxWidth.Set(600f, 0f); - uIElement.Top.Set(220f, 0f); - uIElement.Height.Set(-220f, 1f); - uIElement.HAlign = 0.5f; - UIPanel uIPanel = new UIPanel(); - uIPanel.Width.Set(0f, 1f); - uIPanel.Height.Set(-110f, 1f); - uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; - uIElement.Append(uIPanel); - modList = new UIList(); - modList.Width.Set(-25f, 1f); - modList.Height.Set(0f, 1f); - modList.ListPadding = 5f; - uIPanel.Append(modList); - UIScrollbar uIScrollbar = new UIScrollbar(); - uIScrollbar.SetView(100f, 1000f); - uIScrollbar.Height.Set(0f, 1f); - uIScrollbar.HAlign = 1f; - uIPanel.Append(uIScrollbar); - modList.SetScrollbar(uIScrollbar); - UITextPanel uITextPanel = new UITextPanel("Mod Sources", 0.8f, true); - uITextPanel.HAlign = 0.5f; - uITextPanel.Top.Set(-35f, 0f); - uITextPanel.SetPadding(15f); - uITextPanel.BackgroundColor = new Color(73, 94, 171); - uIElement.Append(uITextPanel); - UITextPanel button = new UITextPanel("Build All", 1f, false); - button.Width.Set(-10f, 0.5f); - button.Height.Set(25f, 0f); - button.VAlign = 1f; - button.Top.Set(-65f, 0f); - button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button.OnClick += new UIElement.MouseEvent(BuildMods); - uIElement.Append(button); - UITextPanel button2 = new UITextPanel("Build + Reload All", 1f, false); - button2.CopyStyle(button); - button2.HAlign = 1f; - button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button2.OnClick += new UIElement.MouseEvent(BuildAndReload); - uIElement.Append(button2); - UITextPanel button3 = new UITextPanel("Back", 1f, false); - button3.CopyStyle(button); - button3.Top.Set(-20f, 0f); - button3.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button3.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button3.OnClick += new UIElement.MouseEvent(BackClick); - uIElement.Append(button3); - UITextPanel button4 = new UITextPanel("Open Sources", 1f, false); - button4.CopyStyle(button3); - button4.HAlign = 1f; - button4.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button4.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button4.OnClick += new UIElement.MouseEvent(OpenSources); - uIElement.Append(button4); - base.Append(uIElement); - } - - private static void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171); - } - - private static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) - { - ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f; - } - - private static void BackClick(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(11, -1, -1, 1); - Main.menuMode = 0; - } - - private static void OpenSources(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - Directory.CreateDirectory(ModLoader.ModSourcePath); - Process.Start(ModLoader.ModSourcePath); - } - - private static void BuildMods(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - ModLoader.reloadAfterBuild = false; - ModLoader.buildAll = true; - Main.menuMode = Interface.buildAllModsID; - } - - private static void BuildAndReload(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - ModLoader.reloadAfterBuild = true; - ModLoader.buildAll = true; - Main.menuMode = Interface.buildAllModsID; - } - - public override void OnActivate() - { - modList.Clear(); - string[] mods = ModLoader.FindModSources(); - foreach(string mod in mods) - { - modList.Add(new UIModSourceItem(mod)); - } - } -}} diff --git a/Terraria.ModLoader.UI/UIMods.cs b/Terraria.ModLoader.UI/UIMods.cs deleted file mode 100644 index 1ea07cb2c6c..00000000000 --- a/Terraria.ModLoader.UI/UIMods.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Terraria.GameContent.UI.Elements; -using Terraria.UI; - -namespace Terraria.ModLoader.UI { -internal class UIMods : UIState -{ - private UIList modList; - private List items = new List(); - public override void OnInitialize() - { - UIElement uIElement = new UIElement(); - uIElement.Width.Set(0f, 0.8f); - uIElement.MaxWidth.Set(600f, 0f); - uIElement.Top.Set(220f, 0f); - uIElement.Height.Set(-220f, 1f); - uIElement.HAlign = 0.5f; - UIPanel uIPanel = new UIPanel(); - uIPanel.Width.Set(0f, 1f); - uIPanel.Height.Set(-110f, 1f); - uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; - uIElement.Append(uIPanel); - modList = new UIList(); - modList.Width.Set(-25f, 1f); - modList.Height.Set(0f, 1f); - modList.ListPadding = 5f; - uIPanel.Append(modList); - UIScrollbar uIScrollbar = new UIScrollbar(); - uIScrollbar.SetView(100f, 1000f); - uIScrollbar.Height.Set(0f, 1f); - uIScrollbar.HAlign = 1f; - uIPanel.Append(uIScrollbar); - modList.SetScrollbar(uIScrollbar); - UITextPanel uITextPanel = new UITextPanel("Mods List", 0.8f, true); - uITextPanel.HAlign = 0.5f; - uITextPanel.Top.Set(-35f, 0f); - uITextPanel.SetPadding(15f); - uITextPanel.BackgroundColor = new Color(73, 94, 171); - uIElement.Append(uITextPanel); - UIColorTextPanel button = new UIColorTextPanel("Enable All", Color.Green, 1f, false); - button.Width.Set(-10f, 0.5f); - button.Height.Set(25f, 0f); - button.VAlign = 1f; - button.Top.Set(-65f, 0f); - button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button.OnClick += new UIElement.MouseEvent(this.EnableAll); - uIElement.Append(button); - UIColorTextPanel button2 = new UIColorTextPanel("Disable All", Color.Red, 1f, false); - button2.CopyStyle(button); - button2.HAlign = 1f; - button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - button2.OnClick += new UIElement.MouseEvent(this.DisableAll); - uIElement.Append(button2); - UITextPanel uITextPanel2 = new UITextPanel("Back", 1f, false); - uITextPanel2.CopyStyle(button); - uITextPanel2.Top.Set(-20f, 0f); - uITextPanel2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - uITextPanel2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - uITextPanel2.OnClick += new UIElement.MouseEvent(BackClick); - uIElement.Append(uITextPanel2); - UITextPanel uITextPanel3 = new UITextPanel("Reload Mods", 1f, false); - uITextPanel3.CopyStyle(uITextPanel2); - uITextPanel3.HAlign = 1f; - uITextPanel3.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); - uITextPanel3.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); - uITextPanel3.OnClick += new UIElement.MouseEvent(ReloadMods); - uIElement.Append(uITextPanel3); - base.Append(uIElement); - } - - private static void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171); - } - - private static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) - { - ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f; - } - - private static void BackClick(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(11, -1, -1, 1); - Main.menuMode = 0; - } - - private static void ReloadMods(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(10, -1, -1, 1); - ModLoader.Reload(); - } - - private void EnableAll(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - foreach(UIModItem modItem in items) - { - if(!modItem.enabled) - { - modItem.ToggleEnabled(evt, listeningElement); - } - } - } - - private void DisableAll(UIMouseEvent evt, UIElement listeningElement) - { - Main.PlaySound(12, -1, -1, 1); - foreach (UIModItem modItem in items) - { - if (modItem.enabled) - { - modItem.ToggleEnabled(evt, listeningElement); - } - } - } - - public override void OnActivate() - { - modList.Clear(); - items.Clear(); - string[] mods = ModLoader.FindMods(); - foreach(string mod in mods) - { - UIModItem modItem = new UIModItem(mod); - modList.Add(modItem); - items.Add(modItem); - } - } -}} diff --git a/Terraria.ModLoader/BuildProperties.cs b/Terraria.ModLoader/BuildProperties.cs deleted file mode 100644 index 87d25f0c790..00000000000 --- a/Terraria.ModLoader/BuildProperties.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Terraria.ModLoader { -internal class BuildProperties -{ - internal string[] dllReferences = new string[0]; - internal string[] modReferences = new string[0]; - internal string author = ""; - internal string version = ""; - internal string displayName = ""; -}} diff --git a/Terraria.ModLoader/CraftGroup.cs b/Terraria.ModLoader/CraftGroup.cs deleted file mode 100644 index f8e6e95f389..00000000000 --- a/Terraria.ModLoader/CraftGroup.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Terraria.ModLoader { -public class CraftGroup -{ - private static readonly IDictionary vanillaGroups = new Dictionary(); - public readonly string Name; - public readonly string DisplayName; - public readonly IList Items = new List(); - - internal CraftGroup(string name, string displayName, params int[] items) - { - Name = name; - DisplayName = displayName; - foreach(int id in items) - { - Items.Add(id); - } - } - - //in Terraria.Recipe rewrite useCraftGroup recipes to check if craft groups contain id - internal static void ResetVanillaGroups() - { - vanillaGroups["Wood"] = new CraftGroup("Wood", Lang.misc[37] + " " + Main.itemName[9], - 9, 619, 620, 621, 911, 1729, 2503, 2504); - vanillaGroups["IronBar"] = new CraftGroup("IronBar", Lang.misc[37] + " " + Main.itemName[22], - 22, 704); - vanillaGroups["PressurePlate"] = new CraftGroup("PressurePlate", Lang.misc[37] + " " + Lang.misc[38], - 529, 541, 542, 543, 852, 853, 1151); - vanillaGroups["Sand"] = new CraftGroup("Sand", Lang.misc[37] + " " + Main.itemName[169], - 169, 408, 1246, 370, 3272); - vanillaGroups["Fragment"] = new CraftGroup("Fragment", Lang.misc[37] + " " + Lang.misc[51], - 3458, 3456, 3457, 3459); - } - - public static CraftGroup GetVanillaGroup(string name) - { - if(vanillaGroups.ContainsKey(name)) - { - return vanillaGroups[name]; - } - else - { - return null; - } - } -}} diff --git a/Terraria.ModLoader/EquipLoader.cs b/Terraria.ModLoader/EquipLoader.cs deleted file mode 100644 index bc532d2a0de..00000000000 --- a/Terraria.ModLoader/EquipLoader.cs +++ /dev/null @@ -1,307 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework.Graphics; -using Terraria; - -namespace Terraria.ModLoader { -public static class EquipLoader -{ - //in Terraria.Main.DrawPlayer and Terraria.Main.DrawPlayerHead get rid of checks for slot too high (not necessary for loading) - private static readonly IDictionary nextEquip = new Dictionary(); - internal static readonly IDictionary> equips = new Dictionary>(); - internal static readonly IDictionary> idToSlot = new Dictionary>(); - internal static readonly IDictionary> slotToId = new Dictionary>(); - internal static readonly IDictionary femaleTextures = new Dictionary(); - internal static readonly IDictionary armTextures = new Dictionary(); - static EquipLoader() - { - foreach(EquipType type in Enum.GetValues(typeof(EquipType))) - { - nextEquip[type] = GetNumVanilla(type); - equips[type] = new Dictionary(); - } - slotToId[EquipType.Head] = new Dictionary(); - slotToId[EquipType.Body] = new Dictionary(); - slotToId[EquipType.Legs] = new Dictionary(); - } - - internal static int ReserveEquipID(EquipType type) - { - int reserveID = nextEquip[type]; - nextEquip[type]++; - return reserveID; - } - - public static int GetEquipSlot(EquipType type, string texture) - { - if(equips[type].ContainsKey(texture)) - { - return equips[type][texture]; - } - else - { - return 0; - } - } - - public static sbyte GetAccessorySlot(EquipType type, string texture) - { - return (sbyte)GetEquipSlot(type, texture); - } - - internal static void ResizeAndFillArrays() - { - Array.Resize(ref Main.armorHeadLoaded, nextEquip[EquipType.Head]); - Array.Resize(ref Main.armorBodyLoaded, nextEquip[EquipType.Body]); - Array.Resize(ref Main.armorLegsLoaded, nextEquip[EquipType.Legs]); - Array.Resize(ref Main.accHandsOnLoaded, nextEquip[EquipType.HandsOn]); - Array.Resize(ref Main.accHandsOffLoaded, nextEquip[EquipType.HandsOff]); - Array.Resize(ref Main.accBackLoaded, nextEquip[EquipType.Back]); - Array.Resize(ref Main.accFrontLoaded, nextEquip[EquipType.Front]); - Array.Resize(ref Main.accShoesLoaded, nextEquip[EquipType.Shoes]); - Array.Resize(ref Main.accWaistLoaded, nextEquip[EquipType.Waist]); - Array.Resize(ref Main.wingsLoaded, nextEquip[EquipType.Wings]); - Array.Resize(ref Main.accShieldLoaded, nextEquip[EquipType.Shield]); - Array.Resize(ref Main.accNeckLoaded, nextEquip[EquipType.Neck]); - Array.Resize(ref Main.accFaceLoaded, nextEquip[EquipType.Face]); - Array.Resize(ref Main.accballoonLoaded, nextEquip[EquipType.Balloon]); - foreach(EquipType type in Enum.GetValues(typeof(EquipType))) - { - for(int k = GetNumVanilla(type); k < nextEquip[type]; k++) - { - GetLoadedArray(type)[k] = true; - } - } - Array.Resize(ref Main.armorHeadTexture, nextEquip[EquipType.Head]); - Array.Resize(ref Main.armorBodyTexture, nextEquip[EquipType.Body]); - Array.Resize(ref Main.femaleBodyTexture, nextEquip[EquipType.Body]); - Array.Resize(ref Main.armorArmTexture, nextEquip[EquipType.Body]); - Array.Resize(ref Main.armorLegTexture, nextEquip[EquipType.Legs]); - Array.Resize(ref Main.accHandsOnTexture, nextEquip[EquipType.HandsOn]); - Array.Resize(ref Main.accHandsOffTexture, nextEquip[EquipType.HandsOff]); - Array.Resize(ref Main.accBackTexture, nextEquip[EquipType.Back]); - Array.Resize(ref Main.accFrontTexture, nextEquip[EquipType.Front]); - Array.Resize(ref Main.accShoesTexture, nextEquip[EquipType.Shoes]); - Array.Resize(ref Main.accWaistTexture, nextEquip[EquipType.Waist]); - Array.Resize(ref Main.wingsTexture, nextEquip[EquipType.Wings]); - Array.Resize(ref Main.accShieldTexture, nextEquip[EquipType.Shield]); - Array.Resize(ref Main.accNeckTexture, nextEquip[EquipType.Neck]); - Array.Resize(ref Main.accFaceTexture, nextEquip[EquipType.Face]); - Array.Resize(ref Main.accBalloonTexture, nextEquip[EquipType.Balloon]); - foreach(EquipType type in Enum.GetValues(typeof(EquipType))) - { - foreach(string texture in equips[type].Keys) - { - int slot = GetEquipSlot(type, texture); - GetTextureArray(type)[slot] = ModLoader.GetTexture(texture); - if(type == EquipType.Body) - { - if(femaleTextures.ContainsKey(slot)) - { - Main.femaleBodyTexture[slot] = ModLoader.GetTexture(femaleTextures[slot]); - } - else - { - Main.femaleBodyTexture[slot] = Main.armorBodyTexture[slot]; - } - Main.armorArmTexture[slot] = ModLoader.GetTexture(armTextures[slot]); - } - } - } - Array.Resize(ref Item.headType, nextEquip[EquipType.Head]); - foreach(int slot in slotToId[EquipType.Head].Keys) - { - Item.headType[slot] = slotToId[EquipType.Head][slot]; - } - Array.Resize(ref Item.bodyType, nextEquip[EquipType.Body]); - foreach(int slot in slotToId[EquipType.Body].Keys) - { - Item.bodyType[slot] = slotToId[EquipType.Body][slot]; - } - Array.Resize(ref Item.legType, nextEquip[EquipType.Legs]); - foreach(int slot in slotToId[EquipType.Legs].Keys) - { - Item.legType[slot] = slotToId[EquipType.Legs][slot]; - } - } - - internal static void Unload() - { - foreach(EquipType type in Enum.GetValues(typeof(EquipType))) - { - nextEquip[type] = GetNumVanilla(type); - equips[type].Clear(); - } - idToSlot.Clear(); - slotToId[EquipType.Head].Clear(); - slotToId[EquipType.Body].Clear(); - slotToId[EquipType.Legs].Clear(); - femaleTextures.Clear(); - armTextures.Clear(); - } - - internal static int GetNumVanilla(EquipType type) - { - switch(type) - { - case EquipType.Head: - return Main.numArmorHead; - case EquipType.Body: - return Main.numArmorBody; - case EquipType.Legs: - return Main.numArmorLegs; - case EquipType.HandsOn: - return Main.numAccHandsOn; - case EquipType.HandsOff: - return Main.numAccHandsOff; - case EquipType.Back: - return Main.numAccBack; - case EquipType.Front: - return Main.numAccFront; - case EquipType.Shoes: - return Main.numAccShoes; - case EquipType.Waist: - return Main.numAccWaist; - case EquipType.Wings: - return Main.maxWings; - case EquipType.Shield: - return Main.numAccShield; - case EquipType.Neck: - return Main.numAccNeck; - case EquipType.Face: - return Main.numAccFace; - case EquipType.Balloon: - return Main.numAccBalloon; - } - return 0; - } - - internal static bool[] GetLoadedArray(EquipType type) - { - switch(type) - { - case EquipType.Head: - return Main.armorHeadLoaded; - case EquipType.Body: - return Main.armorBodyLoaded; - case EquipType.Legs: - return Main.armorLegsLoaded; - case EquipType.HandsOn: - return Main.accHandsOnLoaded; - case EquipType.HandsOff: - return Main.accHandsOffLoaded; - case EquipType.Back: - return Main.accBackLoaded; - case EquipType.Front: - return Main.accFrontLoaded; - case EquipType.Shoes: - return Main.accShoesLoaded; - case EquipType.Waist: - return Main.accWaistLoaded; - case EquipType.Wings: - return Main.wingsLoaded; - case EquipType.Shield: - return Main.accShieldLoaded; - case EquipType.Neck: - return Main.accNeckLoaded; - case EquipType.Face: - return Main.accFaceLoaded; - case EquipType.Balloon: - return Main.accballoonLoaded; - } - return null; - } - - internal static Texture2D[] GetTextureArray(EquipType type) - { - switch (type) - { - case EquipType.Head: - return Main.armorHeadTexture; - case EquipType.Body: - return Main.armorBodyTexture; - case EquipType.Legs: - return Main.armorLegTexture; - case EquipType.HandsOn: - return Main.accHandsOnTexture; - case EquipType.HandsOff: - return Main.accHandsOffTexture; - case EquipType.Back: - return Main.accBackTexture; - case EquipType.Front: - return Main.accFrontTexture; - case EquipType.Shoes: - return Main.accShoesTexture; - case EquipType.Waist: - return Main.accWaistTexture; - case EquipType.Wings: - return Main.wingsTexture; - case EquipType.Shield: - return Main.accShieldTexture; - case EquipType.Neck: - return Main.accNeckTexture; - case EquipType.Face: - return Main.accFaceTexture; - case EquipType.Balloon: - return Main.accBalloonTexture; - } - return null; - } - - internal static void SetSlot(Item item) - { - if(idToSlot.ContainsKey(item.type)) - { - IDictionary slots = idToSlot[item.type]; - foreach(EquipType type in slots.Keys) - { - int slot = slots[type]; - switch (type) - { - case EquipType.Head: - item.headSlot = slot; - break; - case EquipType.Body: - item.bodySlot = slot; - break; - case EquipType.Legs: - item.legSlot = slot; - break; - case EquipType.HandsOn: - item.handOnSlot = (sbyte)slot; - break; - case EquipType.HandsOff: - item.handOffSlot = (sbyte)slot; - break; - case EquipType.Back: - item.backSlot = (sbyte)slot; - break; - case EquipType.Front: - item.frontSlot = (sbyte)slot; - break; - case EquipType.Shoes: - item.shoeSlot = (sbyte)slot; - break; - case EquipType.Waist: - item.waistSlot = (sbyte)slot; - break; - case EquipType.Wings: - item.wingSlot = (sbyte)slot; - break; - case EquipType.Shield: - item.shieldSlot = (sbyte)slot; - break; - case EquipType.Neck: - item.neckSlot = (sbyte)slot; - break; - case EquipType.Face: - item.faceSlot = (sbyte)slot; - break; - case EquipType.Balloon: - item.balloonSlot = (sbyte)slot; - break; - } - } - } - } -}} diff --git a/Terraria.ModLoader/EquipType.cs b/Terraria.ModLoader/EquipType.cs deleted file mode 100644 index d12985f08f6..00000000000 --- a/Terraria.ModLoader/EquipType.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Terraria.ModLoader { -public enum EquipType -{ - Head, - Body, - Legs, - HandsOn, - HandsOff, - Back, - Front, - Shoes, - Waist, - Wings, - Shield, - Neck, - Face, - Balloon -}} diff --git a/Terraria.ModLoader/ErrorLogger.cs b/Terraria.ModLoader/ErrorLogger.cs deleted file mode 100644 index 2f0829e1e15..00000000000 --- a/Terraria.ModLoader/ErrorLogger.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.IO; - -namespace Terraria.ModLoader { -public static class ErrorLogger -{ - public static readonly string LogPath = Main.SavePath + Path.DirectorySeparatorChar + "Logs"; - - internal static void LogModReferenceError(string reference) - { - Directory.CreateDirectory(LogPath); - string file = LogPath + Path.DirectorySeparatorChar + "Compile Errors.txt"; - string message = "Mod reference " + reference + " was not found."; - using(StreamWriter writer = File.CreateText(file)) - { - writer.WriteLine(message); - } - Interface.errorMessage.SetMessage(message); - Interface.errorMessage.SetGotoMenu(Interface.modSourcesID); - Interface.errorMessage.SetFile(file); - } - - internal static void LogCompileErrors(CompilerErrorCollection errors) - { - Directory.CreateDirectory(LogPath); - string file = LogPath + Path.DirectorySeparatorChar + "Compile Errors.txt"; - using (StreamWriter writer = File.CreateText(file)) - { - foreach (CompilerError error in errors) - { - writer.WriteLine(error.ToString()); - writer.WriteLine(); - } - } - Interface.errorMessage.SetMessage("An error occurred while compiling a mod.\n\n" + errors[0]); - Interface.errorMessage.SetGotoMenu(Interface.modSourcesID); - Interface.errorMessage.SetFile(file); - } - - internal static void LogMissingLoadReference(List mods) - { - Directory.CreateDirectory(LogPath); - string file = LogPath + Path.DirectorySeparatorChar + "Loading Errors.txt"; - string message = "The following mods were missing mod dependencies. They have been automatically disabled.\n"; - foreach(string modFile in mods) - { - message += Path.GetFileNameWithoutExtension(modFile) + "\n"; - } - using(StreamWriter writer = File.CreateText(file)) - { - writer.Write(message); - } - Interface.errorMessage.SetMessage(message); - Interface.errorMessage.SetGotoMenu(Interface.reloadModsID); - Interface.errorMessage.SetFile(file); - } - - internal static void LogLoadingError(string modFile, Exception e) - { - Directory.CreateDirectory(LogPath); - string file = LogPath + Path.DirectorySeparatorChar + "Loading Errors.txt"; - using (StreamWriter writer = File.CreateText(file)) - { - writer.WriteLine(e.Message); - writer.WriteLine(e.StackTrace); - } - string message = "An error occurred while loading " + Path.GetFileNameWithoutExtension(modFile); - if (modFile != "recipes") - { - message += "\nThis mod has automatically been disabled."; - } - message += "\n\n" + e.Message + "\n" + e.StackTrace; - Interface.errorMessage.SetMessage(message); - Interface.errorMessage.SetGotoMenu(Interface.reloadModsID); - Interface.errorMessage.SetFile(file); - } - - //add try catch to Terraria.WorldGen.worldGenCallBack - //add try catch to Terraria.WorldGen.playWorldCallBack - //add try catch to Terraria.Main.Update - //add try catch to Terraria.Main.Draw - internal static void LogException(Exception e) - { - Directory.CreateDirectory(LogPath); - string file = LogPath + Path.DirectorySeparatorChar + "Runtime Error.txt"; - using (StreamWriter writer = File.CreateText(file)) - { - writer.WriteLine(e.Message); - writer.WriteLine(e.StackTrace); - } - Interface.errorMessage.SetMessage("The game has crashed!\n\n" + e.Message + "\n" + e.StackTrace); - Interface.errorMessage.SetGotoMenu(0); - Interface.errorMessage.SetFile(file); - Main.gameMenu = true; - Main.menuMode = Interface.errorMessageID; - } - - public static void Log(string message) - { - Directory.CreateDirectory(LogPath); - using (StreamWriter writer = File.AppendText(LogPath + Path.DirectorySeparatorChar + "Logs.txt")) - { - writer.WriteLine(message); - } - } - - public static void ClearLog() - { - Directory.CreateDirectory(LogPath); - using (StreamWriter writer = File.CreateText(LogPath + Path.DirectorySeparatorChar + "Logs.txt")) { } - } -}} diff --git a/Terraria.ModLoader/GlobalItem.cs b/Terraria.ModLoader/GlobalItem.cs deleted file mode 100644 index eb9c74d3227..00000000000 --- a/Terraria.ModLoader/GlobalItem.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; - -namespace Terraria.ModLoader { -public class GlobalItem -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - - public void AddTooltip(Item item, string tooltip) - { - if (item.toolTip == null || item.toolTip.Length == 0) - { - item.toolTip = tooltip; - } - else - { - item.toolTip += Environment.NewLine + tooltip; - } - } - - public void AddTooltip2(Item item, string tooltip) - { - if (item.toolTip2 == null || item.toolTip2.Length == 0) - { - item.toolTip2 = tooltip; - } - else - { - item.toolTip2 += Environment.NewLine + tooltip; - } - } - - public virtual bool Autoload(ref string name) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults(Item item) { } - - public virtual bool CanUseItem(Item item, Player player) - { - return true; - } - - public virtual void UseStyle(Item item, Player player) { } - - public virtual void HoldStyle(Item item, Player player) { } - - public virtual void HoldItem(Item item, Player player) { } - - public virtual bool ConsumeAmmo(Item item, Player player) - { - return true; - } - - public virtual bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - return true; - } - - public virtual void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox) { } - - public virtual void MeleeEffects(Item item, Player player, Rectangle hitbox) { } - - public virtual void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { } - - public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit) { } - - public virtual void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit) { } - - public virtual void OnHitPvp(Item item, Player player, Player target, int damage, bool crit) { } - - public virtual bool UseItem(Item item, Player player) - { - return false; - } - - public virtual bool ConsumeItem(Item item, Player player) - { - return true; - } - - public virtual bool UseItemFrame(Item item, Player player) - { - return false; - } - - public virtual bool HoldItemFrame(Item item, Player player) - { - return false; - } - - public virtual void UpdateInventory(Item item, Player player) { } - - public virtual void UpdateEquip(Item item, Player player) { } - - public virtual void UpdateAccessory(Item item, Player player) { } - - public virtual string IsArmorSet(Item head, Item body, Item legs) - { - return ""; - } - - public virtual void UpdateArmorSet(Player player, string set) { } - - public virtual bool CanRightClick(Item item) - { - return false; - } - - public virtual void RightClick(Item item, Player player) { } - - public virtual bool PreOpenVanillaBag(string context, Player player, int arg) - { - return true; - } - - public virtual void OpenVanillaBag(string context, Player player, int arg) { } - - public virtual void DrawHair(Item item, ref bool drawHair, ref bool drawAltHair) { } - - public virtual bool DrawHead(Item item) - { - return true; - } - - public virtual void VerticalWingSpeeds(Item item, ref float ascentWhenFalling, ref float ascentWhenRising, - ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { } - - public virtual void HorizontalWingSpeeds(Item item, ref float speed, ref float acceleration) { } - - public virtual void Update(Item item, ref float gravity, ref float maxFallSpeed) { } - - public virtual void GrabRange(Item item, Player player, ref int grabRange) { } - - public virtual bool GrabStyle(Item item, Player player) - { - return false; - } - - public virtual bool OnPickup(Item item, Player player) - { - return true; - } - - public virtual Color? GetAlpha(Item item, Color lightColor) - { - return null; - } - - public virtual bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale) - { - return true; - } - - public virtual void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale) { } - - public virtual bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, - Color drawColor, Color itemColor, Vector2 origin, float scale) - { - return true; - } - - public virtual void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, - Color drawColor, Color itemColor, Vector2 origin, float scale) { } - - public virtual bool CanEquipAccessory(Item item, Player player, int slot) - { - return true; - } -}} diff --git a/Terraria.ModLoader/GlobalNPC.cs b/Terraria.ModLoader/GlobalNPC.cs deleted file mode 100644 index 8bc22f3ad26..00000000000 --- a/Terraria.ModLoader/GlobalNPC.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Terraria.ModLoader { -public class GlobalNPC -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - - public virtual bool Autoload(ref string name) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults(NPC npc) { } - - public virtual bool PreNPCLoot(NPC npc) - { - return true; - } - - public virtual void NPCLoot(NPC npc) { } -}} diff --git a/Terraria.ModLoader/GlobalProjectile.cs b/Terraria.ModLoader/GlobalProjectile.cs deleted file mode 100644 index 5527258cdd3..00000000000 --- a/Terraria.ModLoader/GlobalProjectile.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Terraria; - -namespace Terraria.ModLoader { -public class GlobalProjectile -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - - public virtual bool Autoload(ref string name) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults(Projectile projectile) { } -}} diff --git a/Terraria.ModLoader/GlobalTile.cs b/Terraria.ModLoader/GlobalTile.cs deleted file mode 100644 index d2d2c702e93..00000000000 --- a/Terraria.ModLoader/GlobalTile.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using Microsoft.Xna.Framework.Graphics; -using Terraria; - -namespace Terraria.ModLoader { -public class GlobalTile -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - - public void AddToArray(ref int[] array, int type) - { - Array.Resize(ref array, array.Length + 1); - array[array.Length - 1] = type; - } - - public virtual bool Autoload(ref string name) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults() { } - - public virtual bool KillSound(int i, int j, int type) - { - return true; - } - - public virtual void NumDust(int i, int j, int type, bool fail, ref int num) { } - - public virtual bool CreateDust(int i, int j, int type, ref int dustType) - { - return true; - } - - public virtual void DropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance) { } - - public virtual bool Drop(int i, int j, int type) - { - return true; - } - - public virtual bool CanKillTile(int i, int j, int type, ref bool blockDamaged) - { - return true; - } - - public virtual void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) { } - - public virtual void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) { } - - public virtual void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects) { } - - public virtual bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - return true; - } - - public virtual void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) { } - - public virtual void RandomUpdate(int i, int j, int type) { } - - public virtual bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) - { - return true; - } - - public virtual bool CanPlace(int i, int j, int type) - { - return true; - } - - public virtual int[] AdjTiles(int type) - { - return new int[0]; - } - - public virtual void RightClick(int i, int j, int type) { } - - public virtual void MouseOver(int i, int j, int type) { } - - public virtual void HitWire(int i, int j, int type) { } - - public virtual bool Slope(int i, int j, int type) - { - return true; - } -}} diff --git a/Terraria.ModLoader/GlobalWall.cs b/Terraria.ModLoader/GlobalWall.cs deleted file mode 100644 index 186ea635287..00000000000 --- a/Terraria.ModLoader/GlobalWall.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using Microsoft.Xna.Framework.Graphics; -using Terraria; - -namespace Terraria.ModLoader { -public class GlobalWall -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - - public virtual bool Autoload(ref string name) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults() { } - - public virtual bool KillSound(int i, int j, int type) - { - return true; - } - - public virtual void NumDust(int i, int j, int type, bool fail, ref int num) { } - - public virtual bool CreateDust(int i, int j, int type, ref int dustType) - { - return true; - } - - public virtual bool Drop(int i, int j, int type, ref int dropType) - { - return true; - } - - public virtual void KillWall(int i, int j, int type, ref bool fail) { } - - public virtual void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) { } - - public virtual void RandomUpdate(int i, int j, int type) { } - - public virtual bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - return true; - } - - public virtual void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) { } -}} diff --git a/Terraria.ModLoader/Interface.cs b/Terraria.ModLoader/Interface.cs deleted file mode 100644 index b2a258cd894..00000000000 --- a/Terraria.ModLoader/Interface.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using Terraria; -using Terraria.ModLoader.UI; - -namespace Terraria.ModLoader { -internal static class Interface -{ - internal const int modsMenuID = 10000; - internal const int modSourcesID = 10001; - //set initial Main.menuMode to loadModsID - internal const int loadModsID = 10002; - internal const int buildModID = 10003; - internal const int buildAllModsID = 10004; - internal const int errorMessageID = 10005; - internal const int reloadModsID = 10006; - - private static UIMods modsMenu = new UIMods(); - internal static UILoadMods loadMods = new UILoadMods(); - private static UIModSources modSources = new UIModSources(); - internal static UIBuildMod buildMod = new UIBuildMod(); - internal static UIErrorMessage errorMessage = new UIErrorMessage(); - - //add to Terraria.Main.DrawMenu in Main.menuMode == 0 after achievements - //Interface.AddMenuButtons(this, this.selectedMenu, array9, array7, ref num, ref num3, ref num9, ref num4); - internal static void AddMenuButtons(Main main, int selectedMenu, string[] buttonNames, float[] buttonScales, ref int offY, ref int spacing, ref int buttonIndex, ref int numButtons) - { - buttonNames[buttonIndex] = "Mods"; - if(selectedMenu == buttonIndex) - { - Main.PlaySound(10, -1, -1, 1); - Main.menuMode = modsMenuID; - } - buttonIndex++; - numButtons++; - buttonNames[buttonIndex] = "Mod Sources"; - if(selectedMenu == buttonIndex) - { - Main.PlaySound(10, -1, -1, 1); - Main.menuMode = modSourcesID; - } - buttonIndex++; - numButtons++; - offY = 220; - for(int k = 0; k < numButtons; k++) - { - buttonScales[k] = 0.82f; - } - spacing = 45; - } - - //add to end of if else chain of Main.menuMode in Terraria.Main.DrawMenu - //Interface.ModLoaderMenus(this, this.selectedMenu, array9, array7, ref num, ref num3, ref num4); - internal static void ModLoaderMenus(Main main, int selectedMenu, string[] buttonNames, float[] buttonScales, ref int offY, ref int spacing, ref int numButtons) - { - if(Main.menuMode == modsMenuID) - { - Main.MenuUI.SetState(modsMenu); - Main.menuMode = 888; - } - else if(Main.menuMode == modSourcesID) - { - Main.MenuUI.SetState(modSources); - Main.menuMode = 888; - } - else if(Main.menuMode == loadModsID) - { - Main.MenuUI.SetState(loadMods); - Main.menuMode = 888; - ModLoader.Load(); - } - else if(Main.menuMode == buildModID) - { - Main.MenuUI.SetState(buildMod); - Main.menuMode = 888; - ModLoader.BuildMod(); - } - else if(Main.menuMode == buildAllModsID) - { - Main.MenuUI.SetState(buildMod); - Main.menuMode = 888; - ModLoader.BuildAllMods(); - } - else if(Main.menuMode == errorMessageID) - { - Main.MenuUI.SetState(errorMessage); - Main.menuMode = 888; - } - else if(Main.menuMode == reloadModsID) - { - ModLoader.Reload(); - } - } -}} diff --git a/Terraria.ModLoader/ItemLoader.cs b/Terraria.ModLoader/ItemLoader.cs deleted file mode 100644 index 6b16b812c31..00000000000 --- a/Terraria.ModLoader/ItemLoader.cs +++ /dev/null @@ -1,889 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; - -namespace Terraria.ModLoader { -public static class ItemLoader -{ - private static int nextItem = ItemID.Count; - internal static readonly IDictionary items = new Dictionary(); - internal static readonly IList globalItems = new List(); - internal static readonly IList animations = new List(); - - internal static int ReserveItemID() - { - int reserveID = nextItem; - nextItem++; - return reserveID; - } - - public static ModItem GetItem(int type) - { - if (items.ContainsKey(type)) - { - return items[type]; - } - else - { - return null; - } - } - - internal static void ResizeArrays() - { - Array.Resize(ref Main.itemTexture, nextItem); - Array.Resize(ref Main.itemName, nextItem); - Array.Resize(ref Main.itemFlameLoaded, nextItem); - Array.Resize(ref Main.itemFlameTexture, nextItem); - Array.Resize(ref Main.itemAnimations, nextItem); - Array.Resize(ref Item.staff, nextItem); - Array.Resize(ref Item.claw, nextItem); - Array.Resize(ref ItemID.Sets.Deprecated, nextItem); - Array.Resize(ref ItemID.Sets.NeverShiny, nextItem); - Array.Resize(ref ItemID.Sets.ItemIconPulse, nextItem); - Array.Resize(ref ItemID.Sets.ItemNoGravity, nextItem); - Array.Resize(ref ItemID.Sets.ExtractinatorMode, nextItem); - Array.Resize(ref ItemID.Sets.StaffMinionSlotsRequired, nextItem); - Array.Resize(ref ItemID.Sets.ExoticPlantsForDyeTrade, nextItem); - Array.Resize(ref ItemID.Sets.NebulaPickup, nextItem); - Array.Resize(ref ItemID.Sets.AnimatesAsSoul, nextItem); - Array.Resize(ref ItemID.Sets.gunProj, nextItem); - } - - internal static void Unload() - { - items.Clear(); - nextItem = ItemID.Count; - globalItems.Clear(); - animations.Clear(); - } - - internal static bool IsModItem(Item item) - { - return item.type >= ItemID.Count; - } - - //modify saving in Terraria.IO.WorldFile.SaveChests and Terraria.Player.SavePlayer - //replace netID writes with this - internal static void WriteID(Item item, BinaryWriter writer) - { - if (item.netID >= ItemID.Count) - { - int writeID = Int32.MaxValue; - byte[] data; - using (MemoryStream memoryStream = new MemoryStream()) - { - using (BinaryWriter customWriter = new BinaryWriter(memoryStream)) - { - item.modItem.SaveCustomData(customWriter); - customWriter.Flush(); - data = memoryStream.ToArray(); - } - } - if(data.Length > 0) - { - writeID -= 1; - } - writer.Write(writeID); - writer.Write(item.modItem.mod.Name); - writer.Write(Main.itemName[item.type]); - if(data.Length > 0) - { - writer.Write((short)data.Length); - writer.Write(data); - } - } - else - { - writer.Write(item.netID); - } - } - - //modify loading in Terraria.IO.WorldFile.LoadChests and Terraria.Player.LoadPlayer - //replace netDefaults reads with this - //in Terraria.IO.WorldFile.ValidateWorld inside if (num10 > 0) replace fileIO.ReadInt32(); - internal static void ReadID(Item item, BinaryReader reader) - { - int type = reader.ReadInt32(); - if (type >= Int32.MaxValue - 1) - { - bool hasCustomData = type == Int32.MaxValue - 1; - string modName = reader.ReadString(); - string itemName = reader.ReadString(); - Mod mod = ModLoader.GetMod(modName); - if (mod == null) - { - type = 0; - } - else - { - type = mod.ItemType(itemName); - } - item.netDefaults(type); - if(type != 0 && hasCustomData) - { - byte[] data = reader.ReadBytes(reader.ReadInt16()); - using(MemoryStream memoryStream = new MemoryStream(data)) - { - using(BinaryReader customReader = new BinaryReader(memoryStream)) - { - item.modItem.LoadCustomData(customReader); - } - } - } - } - else - { - item.netDefaults(type); - } - } - - //add to Terraria.Item.Prefix - internal static bool MeleePrefix(Item item) - { - if (item.modItem == null) - { - return false; - } - return item.damage > 0 && item.melee && !item.noUseGraphic; - } - - //add to Terraria.Item.Prefix - internal static bool WeaponPrefix(Item item) - { - if (item.modItem == null) - { - return false; - } - return item.damage > 0 && item.melee && item.noUseGraphic; - } - - //add to Terraria.Item.Prefix - internal static bool RangedPrefix(Item item) - { - if (item.modItem == null) - { - return false; - } - return item.damage > 0 && item.ranged; - } - - //add to Terraria.Item.Prefix - internal static bool MagicPrefix(Item item) - { - if (item.modItem == null) - { - return false; - } - return item.damage > 0 && (item.magic || item.summon); - } - - //in Terraria.Item.SetDefaults get rid of type-too-high check - //add near end of Terraria.Item.SetDefaults after setting netID - //in Terraria.Item.SetDefaults move Lang stuff before SetupItem - internal static void SetupItem(Item item) - { - if (IsModItem(item)) - { - GetItem(item.type).SetupItem(item); - } - foreach(GlobalItem globalItem in globalItems) - { - try - { - globalItem.SetDefaults(item); - } - catch - { - ModLoader.DisableMod(globalItem.mod.file); - throw; - } - } - } - - //near end of Terraria.Main.DrawItem before default drawing call - // if(ItemLoader.animations.Contains(item.type)) - // { ItemLoader.DrawAnimatedItem(item, color, alpha, rotation, scale); return; } - internal static void DrawAnimatedItem(Item item, Color color, Color alpha, float rotation, float scale) - { - int frameCount = Main.itemAnimations[item.type].FrameCount; - int frameDuration = Main.itemAnimations[item.type].TicksPerFrame; - Main.itemFrameCounter[item.whoAmI]++; - if (Main.itemFrameCounter[item.whoAmI] >= frameDuration) - { - Main.itemFrameCounter[item.whoAmI] = 0; - Main.itemFrame[item.whoAmI]++; - } - if (Main.itemFrame[item.whoAmI] >= frameCount) - { - Main.itemFrame[item.whoAmI] = 0; - } - Rectangle frame = Main.itemTexture[item.type].Frame(1, frameCount, 0, Main.itemFrame[item.whoAmI]); - float offX = (float)(item.width / 2 - frame.Width / 2); - float offY = (float)(item.height - frame.Height); - Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (float)(frame.Height / 2) + offY), new Rectangle?(frame), alpha, rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f); - if(item.color != default(Color)) - { - Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (float)(frame.Height / 2) + offY), new Rectangle?(frame), item.GetColor(color), rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f); - } - } - - //in Terraria.Player.ItemCheck - // inside block if (this.controlUseItem && this.itemAnimation == 0 && this.releaseUseItem && item.useStyle > 0) - // set initial flag2 to ItemLoader.CanUseItem(item, this) - internal static bool CanUseItem(Item item, Player player) - { - bool flag = true; - if(IsModItem(item)) - { - flag = flag && item.modItem.CanUseItem(player); - } - foreach(GlobalItem globalItem in globalItems) - { - flag = flag && globalItem.CanUseItem(item, player); - } - return flag; - } - - //in Terraria.Player.ItemCheck after useStyle if/else chain call ItemLoader.UseStyle(item, this) - internal static void UseStyle(Item item, Player player) - { - if(IsModItem(item)) - { - item.modItem.UseStyle(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.UseStyle(item, player); - } - } - - //in Terraria.Player.ItemCheck after holdStyle if/else chain call ItemLoader.HoldStyle(item, this) - internal static void HoldStyle(Item item, Player player) - { - if(!player.pulley && player.itemAnimation <= 0) - { - if(IsModItem(item)) - { - item.modItem.HoldStyle(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.HoldStyle(item, player); - } - } - } - - //in Terraria.Player.ItemCheck before this.controlUseItem setting this.releaseUseItem call ItemLoader.HoldItem(item, this) - internal static void HoldItem(Item item, Player player) - { - if(IsModItem(item)) - { - item.modItem.HoldItem(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.HoldItem(item, player); - } - } - - //near end of Terraria.Player.PickAmmo before flag2 is checked add - // if(!ItemLoader.ConsumeAmmo(sItem, item, this)) { flag2 = true; } - internal static bool ConsumeAmmo(Item item, Item ammo, Player player) - { - if(IsModItem(item) && !item.modItem.ConsumeAmmo(player)) - { - return false; - } - if(IsModItem(ammo) && !ammo.modItem.ConsumeAmmo(player)) - { - return false; - } - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.ConsumeAmmo(item, player) || !globalItem.ConsumeAmmo(ammo, player)) - { - return false; - } - } - return true; - } - - //in Terraria.Player.ItemCheck at end of if/else chain for shooting place if on last else - // if(ItemLoader.Shoot(item, this, ref vector2, ref num78, ref num79, ref num71, ref num73, ref num74)) - internal static bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack)) - { - return false; - } - } - if(IsModItem(item)) - { - if(!item.modItem.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack)) - { - return false; - } - } - return true; - } - - //in Terraria.Player.ItemCheck after end of useStyle if/else chain for melee hitbox - // call ItemLoader.UseItemHitbox(item, this, ref r2, ref flag17) - internal static void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox) - { - if(IsModItem(item)) - { - item.modItem.UseItemHitbox(player, ref hitbox, ref noHitbox); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.UseItemHitbox(item, player, ref hitbox, ref noHitbox); - } - } - - //in Terraria.Player.ItemCheck after magma stone dust effect for melee weapons - // call ItemLoader.MeleeEffects(item, this, r2) - internal static void MeleeEffects(Item item, Player player, Rectangle hitbox) - { - if(IsModItem(item)) - { - item.modItem.MeleeEffects(player, hitbox); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.MeleeEffects(item, player, hitbox); - } - } - - //in Terraria.Player.ItemCheck for melee attacks between crit determination and banner damage - // call ItemLoader.ModifyHitNPC(item, this, Main.npc[num292], ref num282, ref num283, ref flag18) - internal static void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) - { - if(IsModItem(item)) - { - item.modItem.ModifyHitNPC(player, target, ref damage, ref knockBack, ref crit); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.ModifyHitNPC(item, player, target, ref damage, ref knockBack, ref crit); - } - } - - //in Terraria.Player.ItemCheck for melee attacks before updating informational accessories - // call ItemLoader.OnHitNPC(item, this, Main.npc[num292], num295, num283, flag18) - internal static void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit) - { - if(IsModItem(item)) - { - item.modItem.OnHitNPC(player, target, damage, knockBack, crit); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.OnHitNPC(item, player, target, damage, knockBack, crit); - } - } - - //in Terraria.Player.ItemCheck for pvp melee attacks between crit determination and damage var - // call ItemLoader.ModifyHitPvp(item, this, Main.player[num302], ref num282, ref flag20) - internal static void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit) - { - if(IsModItem(item)) - { - item.modItem.ModifyHitPvp(player, target, ref damage, ref crit); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.ModifyHitPvp(item, player, target, ref damage, ref crit); - } - } - - //in Terraria.Player.ItemCheck for pvp melee attacks before NetMessage stuff - // call ItemLoader.OnHitPvp(item, this, Main.player[num302], num304, flag20) - internal static void OnHitPvp(Item item, Player player, Player target, int damage, bool crit) - { - if(IsModItem(item)) - { - item.modItem.OnHitPvp(player, target, damage, crit); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.OnHitPvp(item, player, target, damage, crit); - } - } - - //in Terraria.Player.ItemCheck inside block if (this.itemTime == 0 && this.itemAnimation > 0) before hairDye - // call ItemLoader.UseItem(item, this) - internal static void UseItem(Item item, Player player) - { - if(IsModItem(item) && item.modItem.UseItem(player)) - { - player.itemTime = item.useTime; - } - foreach(GlobalItem globalItem in globalItems) - { - if(globalItem.UseItem(item, player)) - { - player.itemTime = item.useTime; - } - } - } - - //near end of Terraria.Player.ItemCheck before flag22 is checked - // call ItemLoader.ConsumeItem(item, this, ref flag22) - internal static void ConsumeItem(Item item, Player player, ref bool consume) - { - if(IsModItem(item) && !item.modItem.ConsumeItem(player)) - { - consume = false; - } - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.ConsumeItem(item, player)) - { - consume = false; - } - } - } - - //in Terraria.Player.PlayerFrame at end of useStyle if/else chain - // call if(ItemLoader.UseItemFrame(this.inventory[this.selectedItem], this)) { return; } - internal static bool UseItemFrame(Item item, Player player) - { - if(IsModItem(item) && item.modItem.UseItemFrame(player)) - { - return true; - } - foreach(GlobalItem globalItem in globalItems) - { - if(globalItem.UseItemFrame(item, player)) - { - return true; - } - } - return false; - } - - //in Terraria.Player.PlayerFrame at end of holdStyle if statements - // call if(ItemLoader.HoldItemFrame(this.inventory[this.selectedItem], this)) { return; } - internal static bool HoldItemFrame(Item item, Player player) - { - if(IsModItem(item) && item.modItem.HoldItemFrame(player)) - { - return true; - } - foreach(GlobalItem globalItem in globalItems) - { - if(globalItem.HoldItemFrame(item, player)) - { - return true; - } - } - return false; - } - - //place at end of first for loop in Terraria.Player.UpdateEquips - // call ItemLoader.UpdateInventory(this.inventory[j], this) - internal static void UpdateInventory(Item item, Player player) - { - if(IsModItem(item)) - { - item.modItem.UpdateInventory(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.UpdateInventory(item, player); - } - } - - //place in second for loop of Terraria.Player.UpdateEquips before prefix checking - // call ItemLoader.UpdateEquip(this.armor[k], this) - internal static void UpdateEquip(Item item, Player player) - { - if(IsModItem(item)) - { - item.modItem.UpdateEquip(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.UpdateEquip(item, player); - } - } - - //place at end of third for loop of Terraria.Player.UpdateEquips - // call ItemLoader.UpdateAccessory(this.armor[l], this) - internal static void UpdateAccessory(Item item, Player player) - { - if(IsModItem(item)) - { - item.modItem.UpdateAccessory(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.UpdateAccessory(item, player); - } - } - - //at end of Terraria.Player.UpdateArmorSets call ItemLoader.UpdateArmorSet(this, this.armor[0], this.armor[1], this.armor[2]) - internal static void UpdateArmorSet(Player player, Item head, Item body, Item legs) - { - if(IsModItem(head) && head.modItem.IsArmorSet(head, body, legs)) - { - head.modItem.UpdateArmorSet(player); - } - if(IsModItem(body) && body.modItem.IsArmorSet(head, body, legs)) - { - body.modItem.UpdateArmorSet(player); - } - if(IsModItem(legs) && legs.modItem.IsArmorSet(head, body, legs)) - { - legs.modItem.UpdateArmorSet(player); - } - foreach(GlobalItem globalItem in globalItems) - { - string set = globalItem.IsArmorSet(head, body, legs); - if(set.Length > 0) - { - globalItem.UpdateArmorSet(player, set); - } - } - } - - //in Terraria.UI.ItemSlot.RightClick in end of item-opening if/else chain before final else - // make else if(ItemLoader.CanRightClick(inv[slot])) - internal static bool CanRightClick(Item item) - { - if(IsModItem(item) && item.modItem.CanRightClick()) - { - return Main.mouseRight; - } - foreach(GlobalItem globalItem in globalItems) - { - if(globalItem.CanRightClick(item)) - { - return Main.mouseRight; - } - } - return false; - } - - //in Terraria.UI.ItemSlot in block from CanRightClick call ItemLoader.RightClick(inv[slot], player) - internal static void RightClick(Item item, Player player) - { - if (Main.mouseRightRelease) - { - if(IsModItem(item)) - { - item.modItem.RightClick(player); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.RightClick(item, player); - } - item.stack--; - if (item.stack == 0) - { - item.SetDefaults(0, false); - } - Main.PlaySound(7, -1, -1, 1); - Main.stackSplit = 30; - Main.mouseRightRelease = false; - Recipe.FindRecipes(); - } - } - - //in beginning of Terraria.Player.openBag methods add - // if(!ItemLoader.PreOpenVanillaBag("bagName", this, arg)) { return; } - internal static bool PreOpenVanillaBag(string context, Player player, int arg) - { - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.PreOpenVanillaBag(context, player, arg)) - { - return false; - } - } - return true; - } - - //in Terraria.Player.openBag methods after PreOpenVanillaBag if statements - // add ItemLoader.OpenVanillaBag("bagname", this, arg); - internal static void OpenVanillaBag(string context, Player player, int arg) - { - foreach(GlobalItem globalItem in globalItems) - { - globalItem.OpenVanillaBag(context, player, arg); - } - } - - //in Terraria.Main.DrawPlayerHead after if statement that sets flag2 to true - // call ItemLoader.DrawHair(drawPlayer, ref flag, ref flag2) - //in Terraria.Main.DrawPlayer after if statement that sets flag5 to true - // call ItemLoader.DrawHair(drawPlayer, ref flag4, ref flag5) - internal static void DrawHair(Player player, ref bool drawHair, ref bool drawAltHair) - { - Item item = player.armor[10].headSlot >= 0 ? player.armor[10] : player.armor[0]; - if(IsModItem(item)) - { - item.modItem.DrawHair(ref drawHair, ref drawAltHair); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.DrawHair(item, ref drawHair, ref drawAltHair); - } - } - - //in Terraria.Main.DrawPlayerHead in if statement after ItemLoader.DrawHair - //and in Terraria.Main.DrawPlayer in if (!drawPlayer.invis && drawPlayer.head != 38 && drawPlayer.head != 135) - // use && with ItemLoader.DrawHead(drawPlayer) - internal static bool DrawHead(Player player) - { - Item item = player.armor[10].headSlot >= 0 ? player.armor[10] : player.armor[0]; - if(IsModItem(item) && !item.modItem.DrawHead()) - { - return false; - } - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.DrawHead(item)) - { - return false; - } - } - return true; - } - - private static Item GetWing(Player player) - { - Item item = null; - for(int k = 3; k < 8 + player.extraAccessorySlots; k++) - { - if (player.armor[k].wingSlot > 0) - { - item = player.armor[k]; - } - } - return item; - } - - //in Terraria.Player.WingMovement after if statements that set num1-5 - // call ItemLoader.VerticalWingSpeeds(this, ref num2, ref num5, ref num4, ref num3, ref num) - internal static void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, - ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) - { - Item item = GetWing(player); - if(item == null) - { - return; - } - if(IsModItem(item)) - { - item.modItem.VerticalWingSpeeds(ref ascentWhenFalling, ref ascentWhenRising, ref maxCanAscendMultiplier, - ref maxAscentMultiplier, ref constantAscend); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.VerticalWingSpeeds(item, ref ascentWhenFalling, ref ascentWhenRising, - ref maxCanAscendMultiplier, ref maxAscentMultiplier, ref constantAscend); - } - } - - //in Terraria.Player.Update after wingsLogic if statements modifying accRunSpeed and runAcceleration - // call ItemLoader.HorizontalWingSpeeds(this) - internal static void HorizontalWingSpeeds(Player player) - { - Item item = GetWing(player); - if(item == null) - { - return; - } - if(IsModItem(item)) - { - item.modItem.HorizontalWingSpeeds(ref player.accRunSpeed, ref player.runAcceleration); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.HorizontalWingSpeeds(item, ref player.accRunSpeed, ref player.runAcceleration); - } - } - - //in Terraria.Item.UpdateItem before item movement (denoted by ItemID.Sets.ItemNoGravity) - // call ItemLoader.Update(this, ref num, ref num2) - internal static void Update(Item item, ref float gravity, ref float maxFallSpeed) - { - if(IsModItem(item)) - { - item.modItem.Update(ref gravity, ref maxFallSpeed); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.Update(item, ref gravity, ref maxFallSpeed); - } - } - - //in Terraria.Player.GrabItems after increasing grab range add - // ItemLoader.GrabRange(Main.item[j], this, ref num); - internal static void GrabRange(Item item, Player player, ref int grabRange) - { - if(IsModItem(item)) - { - item.modItem.GrabRange(player, ref grabRange); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.GrabRange(item, player, ref grabRange); - } - } - - //in Terraria.Player.GrabItems between setting beingGrabbed to true and grab styles add - // if(ItemLoader.GrabStyle(Main.item[j], this)) { } else - internal static bool GrabStyle(Item item, Player player) - { - foreach(GlobalItem globalItem in globalItems) - { - if(globalItem.GrabStyle(item, player)) - { - return true; - } - } - if(IsModItem(item)) - { - return item.modItem.GrabStyle(player); - } - return false; - } - - //in Terraria.Player.GrabItems before special pickup effects add - // if(!ItemLoader.OnPickup(Main.item[j], this)) { Main.item[j] = new Item(); continue; } - internal static bool OnPickup(Item item, Player player) - { - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.OnPickup(item, player)) - { - return false; - } - } - if(IsModItem(item)) - { - return item.modItem.OnPickup(player); - } - return true; - } - - //in Terraria.UI.ItemSlot.GetItemLight remove type too high check - //in beginning of Terraria.Item.GetAlpha call - // Color? modColor = ItemLoader.GetAlpha(this, newColor); - // if(modColor.HasValue) { return modColor.Value; } - internal static Color? GetAlpha(Item item, Color lightColor) - { - foreach(GlobalItem globalItem in globalItems) - { - Color? color = globalItem.GetAlpha(item, lightColor); - if (color.HasValue) - { - return color; - } - } - if (IsModItem(item)) - { - return item.modItem.GetAlpha(lightColor); - } - return null; - } - - //in Terraria.Main.DrawItem after ItemSlot.GetItemLight call - // if(!ItemLoader.PreDrawInWorld(item, Main.spriteBatch, color, alpha, ref rotation, ref scale)) { return; } - internal static bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale) - { - bool flag = true; - if(IsModItem(item) && !item.modItem.PreDrawInWorld(spriteBatch, lightColor, alphaColor, ref rotation, ref scale)) - { - flag = false; - } - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.PreDrawInWorld(item, spriteBatch, lightColor, alphaColor, ref rotation, ref scale)) - { - flag = false; - } - } - return flag; - } - - //in Terraria.Main.DrawItem before every return (including for PreDrawInWorld) and at end of method call - // ItemLoader.PostDrawInWorld(item, Main.spriteBatch, color, alpha, rotation, scale) - internal static void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale) - { - if(IsModItem(item)) - { - item.modItem.PostDrawInWorld(spriteBatch, lightColor, alphaColor, rotation, scale); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.PostDrawInWorld(item, spriteBatch, lightColor, alphaColor, rotation, scale); - } - } - - //in Terraria.UI.ItemSlot.Draw place item-drawing code inside if statement - // if(ItemLoader.PreDrawInInventory(item, spriteBatch, position2, rectangle2, item.GetAlpha(newColor), - // item.GetColor(color), origin, num4 * num3)) - internal static bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, - Color drawColor, Color itemColor, Vector2 origin, float scale) - { - bool flag = true; - foreach(GlobalItem globalItem in globalItems) - { - if (!globalItem.PreDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale)) - { - flag = false; - } - } - if(IsModItem(item) && !item.modItem.PreDrawInInventory(spriteBatch, position, frame, drawColor, itemColor, origin, scale)) - { - flag = false; - } - return flag; - } - - //in Terraria.UI.ItemSlot.Draw after if statement for PreDrawInInventory call - // ItemLoader.PostDrawInInventory(item, spriteBatch, position2, rectangle2, item.GetAlpha(newColor), - // item.GetColor(color), origin, num4 * num3); - internal static void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, - Color drawColor, Color itemColor, Vector2 origin, float scale) - { - if(IsModItem(item)) - { - item.modItem.PostDrawInInventory(spriteBatch, position, frame, drawColor, itemColor, origin, scale); - } - foreach(GlobalItem globalItem in globalItems) - { - globalItem.PostDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale); - } - } - - //in Terraria.UI.ItemSlot.AccCheck replace 2nd and 3rd return false with - // return !ItemLoader.CanEquipAccessory(item, slot) - internal static bool CanEquipAccessory(Item item, int slot) - { - Player player = Main.player[Main.myPlayer]; - if(IsModItem(item) && !item.modItem.CanEquipAccessory(player, slot)) - { - return false; - } - foreach(GlobalItem globalItem in globalItems) - { - if(!globalItem.CanEquipAccessory(item, player, slot)) - { - return false; - } - } - return true; - } -}} diff --git a/Terraria.ModLoader/MapLegend.cs b/Terraria.ModLoader/MapLegend.cs deleted file mode 100644 index c75e7a81273..00000000000 --- a/Terraria.ModLoader/MapLegend.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using Terraria.ID; -using Terraria.Map; -using Terraria.ModLoader; - -namespace Terraria.ModLoader { -public class MapLegend -{ - //change type of Lang.mapLegend to this class - - private string[] legend; - - public MapLegend(int size) - { - legend = new string[size]; - } - - public int Length - { - get - { - return legend.Length; - } - } - - public string this[int i] - { - get - { - return legend[i]; - } - set - { - legend[i] = value; - } - } - - //in Terraria.Main.DrawInventory replace - // Lang.mapLegend[MapHelper.TileToLookup(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62], 0)] - // with Lang.mapLegend.FromType(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62]) - //in Terraria.Main.DrawInfoAccs replace Lang.mapLegend[MapHelper.TileToLookup(Main.player[Main.myPlayer].bestOre, 0)] - // with Lang.mapLegend.FromType(Main.player[Main.myPlayer].bestOre) - public string FromType(int type) - { - if(type >= TileID.Count) - { - return TileLoader.GetTile(type).MapName(0, 0); - } - return this[MapHelper.TileToLookup(type, 0)]; - } - - //in Terraria.Main.DrawMap replace text = Lang.mapLegend[type]; with - // text = Lang.mapLegend[Main.Map[num91, num92]]; - public string this[MapTile mapTile] - { - get - { - Tile tile = Main.tile[mapTile.x, mapTile.y]; - if(tile.active()) - { - if(tile.type >= TileID.Count) - { - return TileLoader.GetTile(tile.type).MapName(tile.frameX, tile.frameY); - } - } - else if(tile.wall >= WallID.Count) - { - return WallLoader.GetWall(tile.wall).mapName; - } - return legend[mapTile.Type]; - } - } -}} diff --git a/Terraria.ModLoader/Mod.cs b/Terraria.ModLoader/Mod.cs deleted file mode 100644 index 50622093e6b..00000000000 --- a/Terraria.ModLoader/Mod.cs +++ /dev/null @@ -1,655 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using Terraria; -using Terraria.DataStructures; - -namespace Terraria.ModLoader { -public abstract class Mod -{ - internal string file; - internal Assembly code; - private string name; - public string Name - { - get - { - return name; - } - } - private ModProperties properties; - public ModProperties Properties - { - get - { - return properties; - } - } - internal readonly IList recipes = new List(); - internal readonly IDictionary craftGroups = new Dictionary(); - internal readonly IDictionary items = new Dictionary(); - internal readonly IDictionary globalItems = new Dictionary(); - internal readonly IDictionary dusts = new Dictionary(); - internal readonly IDictionary tiles = new Dictionary(); - internal readonly IDictionary globalTiles = new Dictionary(); - internal readonly IDictionary walls = new Dictionary(); - internal readonly IDictionary globalWalls = new Dictionary(); - internal readonly IDictionary projectiles = new Dictionary(); - internal readonly IDictionary globalProjectiles = new Dictionary(); - internal readonly IDictionary npcs = new Dictionary(); - internal readonly IDictionary globalNPCs = new Dictionary(); - - /* - * Initializes the mod's information, such as its name. - */ - internal void Init() - { - ModProperties properties = new ModProperties(); - properties.Autoload = false; - SetModInfo(out name, ref properties); - this.properties = properties; - } - - public abstract void SetModInfo(out string name, ref ModProperties properties); - - public virtual void Load() { } - - public virtual void AddCraftGroups() { } - - public void AddCraftGroup(string name, string displayName, params int[] items) - { - CraftGroup group = new CraftGroup(name, displayName, items); - craftGroups[name] = group; - } - - public CraftGroup GetCraftGroup(string name) - { - if(craftGroups.ContainsKey(name)) - { - return craftGroups[name]; - } - else - { - return null; - } - } - - public virtual void AddRecipes() { } - - internal void Autoload() - { - Type[] classes = code.GetTypes(); - foreach(Type type in classes) - { - if(type.IsSubclassOf(typeof(ModItem))) - { - AutoloadItem(type); - } - if(type.IsSubclassOf(typeof(GlobalItem))) - { - AutoloadGlobalItem(type); - } - if(type.IsSubclassOf(typeof(ModDust))) - { - AutoloadDust(type); - } - if(type.IsSubclassOf(typeof(ModTile))) - { - AutoloadTile(type); - } - if(type.IsSubclassOf(typeof(GlobalTile))) - { - AutoloadGlobalTile(type); - } - if(type.IsSubclassOf(typeof(ModWall))) - { - AutoloadWall(type); - } - if(type.IsSubclassOf(typeof(GlobalWall))) - { - AutoloadGlobalWall(type); - } - if(type.IsSubclassOf(typeof(ModProjectile))) - { - AutoloadProjectile(type); - } - if(type.IsSubclassOf(typeof(GlobalProjectile))) - { - AutoloadGlobalProjectile(type); - } - if(type.IsSubclassOf(typeof(ModNPC))) - { - AutoloadNPC(type); - } - if(type.IsSubclassOf(typeof(GlobalNPC))) - { - AutoloadGlobalNPC(type); - } - } - } - - public void AddItem(string name, ModItem item, string texture) - { - int id = ItemLoader.ReserveItemID(); - item.item.name = name; - item.item.ResetStats(id); - items[name] = item; - ItemLoader.items[id] = item; - item.texture = texture; - item.mod = this; - } - - public ModItem GetItem(string name) - { - if (items.ContainsKey(name)) - { - return items[name]; - } - else - { - return null; - } - } - - public int ItemType(string name) - { - ModItem item = GetItem(name); - if(item == null) - { - return 0; - } - return item.item.type; - } - - public void AddGlobalItem(string name, GlobalItem globalItem) - { - globalItem.mod = this; - globalItem.Name = name; - this.globalItems[name] = globalItem; - ItemLoader.globalItems.Add(globalItem); - } - - public GlobalItem GetGlobalItem(string name) - { - if(this.globalItems.ContainsKey(name)) - { - return this.globalItems[name]; - } - else - { - return null; - } - } - - public int AddEquipTexture(ModItem item, EquipType type, string texture, string armTexture = "", string femaleTexture = "") - { - int slot = EquipLoader.ReserveEquipID(type); - EquipLoader.equips[type][texture] = slot; - ModLoader.GetTexture(texture); - if(type == EquipType.Body) - { - EquipLoader.armTextures[slot] = armTexture; - EquipLoader.femaleTextures[slot] = femaleTexture.Length > 0 ? femaleTexture : texture; - ModLoader.GetTexture(armTexture); - ModLoader.GetTexture(femaleTexture); - } - if(type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs) - { - EquipLoader.slotToId[type][slot] = item.item.type; - } - return slot; - } - - private void AutoloadItem(Type type) - { - ModItem item = (ModItem)Activator.CreateInstance(type); - item.mod = this; - string name = type.Name; - string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); - IList equips = new List(); - if(item.Autoload(ref name, ref texture, equips)) - { - AddItem(name, item, texture); - if(equips.Count > 0) - { - EquipLoader.idToSlot[item.item.type] = new Dictionary(); - foreach(EquipType equip in equips) - { - string equipTexture = texture + "_" + equip.ToString(); - string armTexture = texture + "_Arms"; - string femaleTexture = texture + "_FemaleBody"; - item.AutoloadEquip(equip, ref equipTexture, ref armTexture, ref femaleTexture); - int slot = AddEquipTexture(item, equip, equipTexture, armTexture, femaleTexture); - EquipLoader.idToSlot[item.item.type][equip] = slot; - } - } - } - } - - private void AutoloadGlobalItem(Type type) - { - GlobalItem globalItem = (GlobalItem)Activator.CreateInstance(type); - globalItem.mod = this; - string name = type.Name; - if(globalItem.Autoload(ref name)) - { - AddGlobalItem(name, globalItem); - } - } - - public void AddDust(string name, ModDust dust, string texture = "") - { - dust.Name = name; - if(texture.Length > 0) - { - dust.Texture = ModLoader.GetTexture(texture); - } - else - { - dust.Texture = Main.dustTexture; - } - dust.mod = this; - dusts[name] = dust; - } - - private void AutoloadDust(Type type) - { - ModDust dust = (ModDust)Activator.CreateInstance(type); - dust.mod = this; - string name = type.Name; - string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); - if(dust.Autoload(ref name, ref texture)) - { - AddDust(name, dust, texture); - } - } - - public void AddTile(string name, ModTile tile, string texture) - { - int id = TileLoader.ReserveTileID(); - tile.Name = name; - tile.Type = (ushort)id; - tiles[name] = tile; - TileLoader.tiles[id] = tile; - tile.texture = texture; - tile.mod = this; - } - - public ModTile GetTile(string name) - { - if (tiles.ContainsKey(name)) - { - return tiles[name]; - } - else - { - return null; - } - } - - public int TileType(string name) - { - ModTile tile = GetTile(name); - if (tile == null) - { - return 0; - } - return (int)tile.Type; - } - - public void AddGlobalTile(string name, GlobalTile globalTile) - { - globalTile.mod = this; - globalTile.Name = name; - this.globalTiles[name] = globalTile; - TileLoader.globalTiles.Add(globalTile); - } - - public GlobalTile GetGlobalTile(string name) - { - if(this.globalTiles.ContainsKey(name)) - { - return globalTiles[name]; - } - else - { - return null; - } - } - - private void AutoloadTile(Type type) - { - ModTile tile = (ModTile)Activator.CreateInstance(type); - tile.mod = this; - string name = type.Name; - string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); - if (tile.Autoload(ref name, ref texture)) - { - AddTile(name, tile, texture); - } - } - - private void AutoloadGlobalTile(Type type) - { - GlobalTile globalTile = (GlobalTile)Activator.CreateInstance(type); - globalTile.mod = this; - string name = type.Name; - if(globalTile.Autoload(ref name)) - { - AddGlobalTile(name, globalTile); - } - } - - public void AddWall(string name, ModWall wall, string texture) - { - int id = WallLoader.ReserveWallID(); - wall.Name = name; - wall.Type = (ushort)id; - walls[name] = wall; - WallLoader.walls[id] = wall; - wall.texture = texture; - wall.mod = this; - } - - public ModWall GetWall(string name) - { - if (walls.ContainsKey(name)) - { - return walls[name]; - } - else - { - return null; - } - } - - public int WallType(string name) - { - ModWall wall = GetWall(name); - if (wall == null) - { - return 0; - } - return (int)wall.Type; - } - - public void AddGlobalWall(string name, GlobalWall globalWall) - { - globalWall.mod = this; - globalWall.Name = name; - this.globalWalls[name] = globalWall; - WallLoader.globalWalls.Add(globalWall); - } - - public GlobalWall GetGlobalWall(string name) - { - if (this.globalWalls.ContainsKey(name)) - { - return globalWalls[name]; - } - else - { - return null; - } - } - - private void AutoloadWall(Type type) - { - ModWall wall = (ModWall)Activator.CreateInstance(type); - wall.mod = this; - string name = type.Name; - string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); - if(wall.Autoload(ref name, ref texture)) - { - AddWall(name, wall, texture); - } - } - - private void AutoloadGlobalWall(Type type) - { - GlobalWall globalWall = (GlobalWall)Activator.CreateInstance(type); - globalWall.mod = this; - string name = type.Name; - if(globalWall.Autoload(ref name)) - { - AddGlobalWall(name, globalWall); - } - } - - public void AddProjectile(string name, ModProjectile projectile, string texture) - { - int id = ProjectileLoader.ReserveProjectileID(); - projectile.projectile.name = name; - projectile.Name = name; - projectile.projectile.type = id; - projectiles[name] = projectile; - ProjectileLoader.projectiles[id] = projectile; - projectile.texture = texture; - projectile.mod = this; - } - - public ModProjectile GetProjectile(string name) - { - if(projectiles.ContainsKey(name)) - { - return projectiles[name]; - } - else - { - return null; - } - } - - public int ProjectileType(string name) - { - ModProjectile projectile = GetProjectile(name); - if(projectile == null) - { - return 0; - } - return projectile.projectile.type; - } - - public void AddGlobalProjectile(string name, GlobalProjectile globalProjectile) - { - globalProjectile.mod = this; - globalProjectile.Name = name; - this.globalProjectiles[name] = globalProjectile; - ProjectileLoader.globalProjectiles.Add(globalProjectile); - } - - public GlobalProjectile GetGlobalProjectile(string name) - { - if(this.globalProjectiles.ContainsKey(name)) - { - return this.globalProjectiles[name]; - } - else - { - return null; - } - } - - private void AutoloadProjectile(Type type) - { - ModProjectile projectile = (ModProjectile)Activator.CreateInstance(type); - projectile.mod = this; - string name = type.Name; - string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); - if(projectile.Autoload(ref name, ref texture)) - { - AddProjectile(name, projectile, texture); - } - } - - private void AutoloadGlobalProjectile(Type type) - { - GlobalProjectile globalProjectile = (GlobalProjectile)Activator.CreateInstance(type); - globalProjectile.mod = this; - string name = type.Name; - if (globalProjectile.Autoload(ref name)) - { - AddGlobalProjectile(name, globalProjectile); - } - } - - public void AddNPC(string name, ModNPC npc, string texture) - { - int id = NPCLoader.ReserveNPCID(); - npc.npc.name = name; - npc.npc.type = id; - npcs[name] = npc; - NPCLoader.npcs[id] = npc; - npc.texture = texture; - npc.mod = this; - } - - public ModNPC GetNPC(string name) - { - if (npcs.ContainsKey(name)) - { - return npcs[name]; - } - else - { - return null; - } - } - - public int NPCType(string name) - { - ModNPC npc = GetNPC(name); - if (npc == null) - { - return 0; - } - return npc.npc.type; - } - - public void AddGlobalNPC(string name, GlobalNPC globalNPC) - { - globalNPC.mod = this; - globalNPC.Name = name; - this.globalNPCs[name] = globalNPC; - NPCLoader.globalNPCs.Add(globalNPC); - } - - public GlobalNPC GetGlobalNPC(string name) - { - if(this.globalNPCs.ContainsKey(name)) - { - return this.globalNPCs[name]; - } - else - { - return null; - } - } - - private void AutoloadNPC(Type type) - { - ModNPC npc = (ModNPC)Activator.CreateInstance(type); - npc.mod = this; - string name = type.Name; - string texture = (type.Namespace + "." + type.Name).Replace('.', '/'); - if(npc.Autoload(ref name, ref texture)) - { - AddNPC(name, npc, texture); - } - } - - private void AutoloadGlobalNPC(Type type) - { - GlobalNPC globalNPC = (GlobalNPC)Activator.CreateInstance(type); - globalNPC.mod = this; - string name = type.Name; - if(globalNPC.Autoload(ref name)) - { - AddGlobalNPC(name, globalNPC); - } - } - - internal void SetupContent() - { - foreach(ModItem item in items.Values) - { - Main.itemTexture[item.item.type] = ModLoader.GetTexture(item.texture); - Main.itemName[item.item.type] = item.item.name; - EquipLoader.SetSlot(item.item); - item.SetDefaults(); - DrawAnimation animation = item.GetAnimation(); - if(animation != null) - { - Main.RegisterItemAnimation(item.item.type, animation); - ItemLoader.animations.Add(item.item.type); - } - } - foreach(ModTile tile in tiles.Values) - { - Main.tileTexture[tile.Type] = ModLoader.GetTexture(tile.texture); - TileLoader.SetDefaults(tile); - } - foreach(GlobalTile globalTile in globalTiles.Values) - { - globalTile.SetDefaults(); - } - foreach(ModWall wall in walls.Values) - { - Main.wallTexture[wall.Type] = ModLoader.GetTexture(wall.texture); - wall.SetDefaults(); - } - foreach(GlobalWall globalWall in globalWalls.Values) - { - globalWall.SetDefaults(); - } - foreach(ModProjectile projectile in projectiles.Values) - { - Main.projectileTexture[projectile.projectile.type] = ModLoader.GetTexture(projectile.texture); - Main.projFrames[projectile.projectile.type] = 1; - projectile.SetDefaults(); - if(projectile.projectile.hostile) - { - Main.projHostile[projectile.projectile.type] = true; - } - if(projectile.projectile.aiStyle == 7) - { - Main.projHook[projectile.projectile.type] = true; - } - } - foreach(ModNPC npc in npcs.Values) - { - Main.npcTexture[npc.npc.type] = ModLoader.GetTexture(npc.texture); - Main.npcName[npc.npc.type] = npc.npc.name; - npc.SetDefaults(); - if(npc.npc.lifeMax > 32767 || npc.npc.boss) - { - Main.npcLifeBytes[npc.npc.type] = 4; - } - else if(npc.npc.lifeMax > 127) - { - Main.npcLifeBytes[npc.npc.type] = 2; - } - else - { - Main.npcLifeBytes[npc.npc.type] = 1; - } - } - } - - internal void Unload() //I'm not sure why I have this - { - recipes.Clear(); - craftGroups.Clear(); - items.Clear(); - globalItems.Clear(); - dusts.Clear(); - tiles.Clear(); - globalTiles.Clear(); - walls.Clear(); - globalWalls.Clear(); - projectiles.Clear(); - globalProjectiles.Clear(); - npcs.Clear(); - globalNPCs.Clear(); - } -}} \ No newline at end of file diff --git a/Terraria.ModLoader/ModDust.cs b/Terraria.ModLoader/ModDust.cs deleted file mode 100644 index fb9cbcfef1e..00000000000 --- a/Terraria.ModLoader/ModDust.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; - -namespace Terraria.ModLoader { -public class ModDust -{ - //in Terraria.Dust add ModDust property (internal set) - //in Terraria.Dust.NewDust set dust.modDust to null - //in Terraria.Dust.CloneDust copy modDust property - - public string Name - { - get; - internal set; - } - public Texture2D Texture - { - get; - internal set; - } - public Mod mod - { - get; - internal set; - } - - public static int NewDust(Vector2 Position, int Width, int Height, Mod mod, string name, float SpeedX = 0f, float SpeedY = 0f, int Alpha = 0, Color newColor = default(Color), float Scale = 1f) - { - int dust = Dust.NewDust(Position, Width, Height, 0, SpeedX, SpeedY, Alpha, newColor, Scale); - Main.dust[dust].modDust = mod.dusts[name]; - mod.dusts[name].OnSpawn(Main.dust[dust]); - return dust; - } - - //in Terraria.Main.DrawDust before universal dust drawing call - // if(dust.modDust != null) { dust.modDust.Draw(dust, color5, scale); continue; } - internal void Draw(Dust dust, Color alpha, float scale) - { - Main.spriteBatch.Draw(Texture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), alpha, dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f); - if (dust.color != default(Microsoft.Xna.Framework.Color)) - { - Main.spriteBatch.Draw(Texture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), dust.GetColor(alpha), dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f); - } - if (alpha == Microsoft.Xna.Framework.Color.Black) - { - dust.active = false; - } - } - - public virtual bool Autoload(ref string name, ref string texture) - { - return mod.Properties.Autoload; - } - - public virtual void OnSpawn(Dust dust) { } - - //in Terraria.Dust.UpdateDust after incrementing Dust.dCount call - // if(dust.modDust != null && !dust.modDust.Update(dust)) { continue; } - public virtual bool Update(Dust dust) - { - return true; - } - - //in beginning of Terraria.Dust.GetAlpha add - // if(this.modDust != null) - // { - // Color? modColor = this.modDust.GetAlpha(this, newColor); - // if(modColor.HasValue) - // { - // return modColor.Value; - // } - // } - public virtual Color? GetAlpha(Dust dust, Color lightColor) - { - return null; - } -}} diff --git a/Terraria.ModLoader/ModItem.cs b/Terraria.ModLoader/ModItem.cs deleted file mode 100644 index 8494d505658..00000000000 --- a/Terraria.ModLoader/ModItem.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; - -namespace Terraria.ModLoader { -public class ModItem -{ - //add modItem property to Terraria.Item (internal set) - //set modItem to null at beginning of Terraria.Item.ResetStats - public Item item - { - get; - internal set; - } - public Mod mod - { - get; - internal set; - } - internal string texture; - public ModItem() - { - item = new Item(); - item.modItem = this; - } - - public void AddTooltip(string tooltip) - { - if(item.toolTip == null || item.toolTip.Length == 0) - { - item.toolTip = tooltip; - } - else - { - item.toolTip += Environment.NewLine + tooltip; - } - } - - public void AddTooltip2(string tooltip) - { - if(item.toolTip2 == null || item.toolTip2.Length == 0) - { - item.toolTip2 = tooltip; - } - else - { - item.toolTip2 += Environment.NewLine + tooltip; - } - } - - public virtual bool Autoload(ref string name, ref string texture, IList equips) - { - return mod.Properties.Autoload; - } - - public virtual void AutoloadEquip(EquipType equip, ref string texture, ref string armTexture, ref string femaleTexture) { } - - public virtual DrawAnimation GetAnimation() - { - return null; - } - - public virtual void SetDefaults() {} - - public virtual bool CanUseItem(Player player) - { - return true; - } - - public virtual void UseStyle(Player player) { } - - public virtual void HoldStyle(Player player) { } - - public virtual void HoldItem(Player player) { } - - public virtual bool ConsumeAmmo(Player player) - { - return true; - } - - public virtual bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - return true; - } - - public virtual void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) { } - - public virtual void MeleeEffects(Player player, Rectangle hitbox) { } - - public virtual void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { } - - public virtual void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { } - - public virtual void ModifyHitPvp(Player player, Player target, ref int damage, ref bool crit) { } - - public virtual void OnHitPvp(Player player, Player target, int damage, bool crit) { } - - public virtual bool UseItem(Player player) - { - return false; - } - - public virtual bool ConsumeItem(Player player) - { - return true; - } - - public virtual bool UseItemFrame(Player player) - { - return false; - } - - public virtual bool HoldItemFrame(Player player) - { - return false; - } - - public virtual void UpdateInventory(Player player) { } - - public virtual void UpdateEquip(Player player) { } - - public virtual void UpdateAccessory(Player player) { } - - public virtual bool IsArmorSet(Item head, Item body, Item legs) - { - return false; - } - - public virtual void UpdateArmorSet(Player player) { } - - public virtual bool CanRightClick() - { - return false; - } - - public virtual void RightClick(Player player) { } - - public virtual void DrawHair(ref bool drawHair, ref bool drawAltHair) { } - - public virtual bool DrawHead() - { - return true; - } - - public virtual void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising, - ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { } - - public virtual void HorizontalWingSpeeds(ref float speed, ref float acceleration) { } - - public virtual void Update(ref float gravity, ref float maxFallSpeed) { } - - public virtual void GrabRange(Player player, ref int grabRange) { } - - public virtual bool GrabStyle(Player player) - { - return false; - } - - public virtual bool OnPickup(Player player) - { - return true; - } - - public virtual Color? GetAlpha(Color lightColor) - { - return null; - } - - public virtual bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale) - { - return true; - } - - public virtual void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale) { } - - public virtual bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, - Color itemColor, Vector2 origin, float scale) - { - return true; - } - - public virtual void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, - Color itemColor, Vector2 origin, float scale) { } - - public virtual bool CanEquipAccessory(Player player, int slot) - { - return true; - } - - internal void SetupItem(Item item) - { - SetupModItem(item); - EquipLoader.SetSlot(item); - item.modItem.SetDefaults(); - } - - //change Terraria.Item.Clone - // Item newItem = (Item)base.MemberwiseClone(); - // if (newItem.type >= ItemID.Count) - // { - // ItemLoader.GetItem(newItem.type).SetupModItem(newItem); - // } - // return newItem; - internal void SetupModItem(Item item) - { - ModItem newItem = (ModItem)Activator.CreateInstance(GetType()); - newItem.item = item; - item.modItem = newItem; - newItem.mod = mod; - } - - public virtual void SaveCustomData(BinaryWriter writer) { } - - public virtual void LoadCustomData(BinaryReader reader) { } - - public virtual void AddRecipes() { } -}} \ No newline at end of file diff --git a/Terraria.ModLoader/ModLoader.cs b/Terraria.ModLoader/ModLoader.cs deleted file mode 100644 index 3f23b9d3d00..00000000000 --- a/Terraria.ModLoader/ModLoader.cs +++ /dev/null @@ -1,704 +0,0 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; -using Microsoft.CSharp; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; - -namespace Terraria.ModLoader { -public static class ModLoader -{ - //change Terraria.Main.SavePath to use "ModLoader" folder - public static readonly string ModPath = Main.SavePath + Path.DirectorySeparatorChar + "Mods"; - public static readonly string ModSourcePath = Main.SavePath + Path.DirectorySeparatorChar + "Mod Sources"; - public static readonly string DllPath = Main.SavePath + Path.DirectorySeparatorChar + "dllReferences"; - private static bool referencesLoaded = false; - private static bool assemblyResolverAdded = false; - private static readonly IList buildReferences = new List(); - internal const int earliestRelease = 149; - internal static string modToBuild; - internal static bool reloadAfterBuild = false; - internal static bool buildAll = false; - private static readonly IList loadedMods = new List(); - internal static readonly IDictionary mods = new Dictionary(); - private static readonly IDictionary textures = new Dictionary(); - - private static void LoadReferences() - { - if(referencesLoaded) - { - return; - } - Assembly current = Assembly.GetExecutingAssembly(); - buildReferences.Add(current.Location); - AssemblyName[] references = current.GetReferencedAssemblies(); - foreach (AssemblyName reference in references) - { - buildReferences.Add(Assembly.Load(reference).Location); - } - referencesLoaded = true; - } - - private static void AddAssemblyResolver() - { - if(assemblyResolverAdded) - { - return; - } - AppDomain.CurrentDomain.AssemblyResolve += ResolveDllReference; - AppDomain.CurrentDomain.AssemblyResolve += ResolveModReference; - assemblyResolverAdded = true; - } - - private static Assembly ResolveDllReference(object sender, ResolveEventArgs args) - { - Directory.CreateDirectory(DllPath); - string name = args.Name; - if(name.IndexOf(',') >= 0) - { - name = name.Substring(0, name.IndexOf(',')); - } - try - { - return Assembly.LoadFrom(DllPath + Path.DirectorySeparatorChar + name + ".dll"); - } - catch - { - return null; - } - } - - private static Assembly ResolveModReference(object sender, ResolveEventArgs args) - { - string name = args.Name; - if(name.IndexOf(',') >= 0) - { - name = name.Substring(0, name.IndexOf(',')); - } - Mod mod = GetMod(name); - if(mod == null) - { - return null; - } - return mod.code; - } - - internal static bool ModLoaded(string name) - { - return loadedMods.Contains(name); - } - - public static Mod GetMod(string name) - { - if(mods.ContainsKey(name)) - { - return mods[name]; - } - return null; - } - - internal static void Load() - { - ThreadPool.QueueUserWorkItem(new WaitCallback(do_Load), 1); - } - - private static void do_Load(object threadContext) - { - if(!LoadMods()) - { - Main.menuMode = Interface.errorMessageID; - return; - } - int num = 0; - foreach(Mod mod in mods.Values) - { - Interface.loadMods.SetProgressInit(mod.Name, num, mods.Count); - try - { - mod.Autoload(); - mod.Load(); - } - catch(Exception e) - { - DisableMod(mod.file); - ErrorLogger.LogLoadingError(mod.file, e); - Main.menuMode = Interface.errorMessageID; - return; - } - num++; - } - Interface.loadMods.SetProgressSetup(0f); - ResizeArrays(); - num = 0; - foreach(Mod mod in mods.Values) - { - Interface.loadMods.SetProgressLoad(mod.Name, num, mods.Count); - try - { - mod.SetupContent(); - } - catch(Exception e) - { - DisableMod(mod.file); - ErrorLogger.LogLoadingError(mod.file, e); - Main.menuMode = Interface.errorMessageID; - return; - } - num++; - } - Interface.loadMods.SetProgressRecipes(); - Recipe.numRecipes = 0; - try - { - CraftGroup.ResetVanillaGroups(); - AddCraftGroups(); - Recipe.SetupRecipes(); - } - catch(Exception e) - { - ErrorLogger.LogLoadingError("recipes", e); - Main.menuMode = Interface.errorMessageID; - return; - } - Main.menuMode = 0; - } - - private static void ResizeArrays(bool unloading = false) - { - ItemLoader.ResizeArrays(); - EquipLoader.ResizeAndFillArrays(); - Main.InitializeItemAnimations(); - TileLoader.ResizeArrays(unloading); - WallLoader.ResizeArrays(unloading); - ProjectileLoader.ResizeArrays(); - NPCLoader.ResizeArrays(); - } - - internal static string[] FindMods() - { - Directory.CreateDirectory(ModPath); - return Directory.GetFiles(ModPath, "*.tmod", SearchOption.TopDirectoryOnly); - } - - private static bool LoadMods() - { - Interface.loadMods.SetProgressFinding(); - string[] modFiles = FindMods(); - List enabledMods = new List(); - foreach(string modFile in modFiles) - { - if (IsEnabled(modFile)) - { - enabledMods.Add(modFile); - } - } - IDictionary properties = new Dictionary(); - List modsToLoad = new List(); - foreach(string modFile in enabledMods) - { - properties[modFile] = LoadBuildProperties(modFile); - modsToLoad.Add(modFile); - } - int previousCount = 0; - int num = 0; - while(modsToLoad.Count > 0 && modsToLoad.Count != previousCount) - { - previousCount = modsToLoad.Count; - int k = 0; - while(k < modsToLoad.Count) - { - bool canLoad = true; - foreach(string reference in properties[modsToLoad[k]].modReferences) - { - if(!ModLoaded(ModPath + Path.DirectorySeparatorChar + reference + ".tmod")) - { - canLoad = false; - break; - } - } - if(canLoad) - { - Interface.loadMods.SetProgressReading(Path.GetFileNameWithoutExtension(modsToLoad[k]), num, enabledMods.Count); - try - { - LoadMod(modsToLoad[k], properties[modsToLoad[k]]); - } - catch (Exception e) - { - DisableMod(modsToLoad[k]); - ErrorLogger.LogLoadingError(modsToLoad[k], e); - return false; - } - loadedMods.Add(modsToLoad[k]); - num++; - modsToLoad.RemoveAt(k); - } - else - { - k++; - } - } - } - if(modsToLoad.Count > 0) - { - foreach(string modFile in modsToLoad) - { - DisableMod(modFile); - } - ErrorLogger.LogMissingLoadReference(modsToLoad); - return false; - } - return true; - } - - private static void LoadMod(string modFile, BuildProperties properties) - { - AddAssemblyResolver(); - Assembly modCode; - using(FileStream fileStream = File.OpenRead(modFile)) - { - using(BinaryReader reader = new BinaryReader(fileStream)) - { - fileStream.Seek(reader.ReadInt32(), SeekOrigin.Current); - modCode = Assembly.Load(reader.ReadBytes(reader.ReadInt32())); - for(string texturePath = reader.ReadString(); texturePath != "end"; texturePath = reader.ReadString()) - { - byte[] imageData = reader.ReadBytes(reader.ReadInt32()); - using(MemoryStream buffer = new MemoryStream(imageData)) - { - textures[texturePath] = Texture2D.FromStream(Main.instance.GraphicsDevice, buffer); - } - } - } - } - Type[] classes = modCode.GetTypes(); - foreach(Type type in classes) - { - if(type.IsSubclassOf(typeof(Mod))) - { - Mod mod = (Mod)Activator.CreateInstance(type); - mod.file = modFile; - mod.code = modCode; - mod.Init(); - mods[mod.Name] = mod; - } - } - } - - internal static BuildProperties LoadBuildProperties(string modFile) - { - BuildProperties properties = new BuildProperties(); - byte[] data; - using(FileStream fileStream = File.OpenRead(modFile)) - { - using(BinaryReader reader = new BinaryReader(fileStream)) - { - data = reader.ReadBytes(reader.ReadInt32()); - } - } - if(data.Length == 0) - { - return properties; - } - using(MemoryStream memoryStream = new MemoryStream(data)) - { - using(BinaryReader reader = new BinaryReader(memoryStream)) - { - for(string tag = reader.ReadString(); tag.Length > 0; tag = reader.ReadString()) - { - if(tag == "dllReferences") - { - List dllReferences = new List(); - for(string reference = reader.ReadString(); reference.Length > 0; reference = reader.ReadString()) - { - dllReferences.Add(reference); - } - properties.dllReferences = dllReferences.ToArray(); - } - if(tag == "modReferences") - { - List modReferences = new List(); - for(string reference = reader.ReadString(); reference.Length > 0; reference = reader.ReadString()) - { - modReferences.Add(reference); - } - properties.modReferences = modReferences.ToArray(); - } - if(tag == "author") - { - properties.author = reader.ReadString(); - } - if(tag == "version") - { - properties.version = reader.ReadString(); - } - if(tag == "displayName") - { - properties.displayName = reader.ReadString(); - } - } - } - } - return properties; - } - - internal static void Unload() - { - foreach(Mod mod in mods.Values) - { - mod.Unload(); - } - loadedMods.Clear(); - ItemLoader.Unload(); - EquipLoader.Unload(); - TileLoader.Unload(); - WallLoader.Unload(); - ProjectileLoader.Unload(); - NPCLoader.Unload(); - textures.Clear(); - mods.Clear(); - ResizeArrays(true); - } - - internal static void Reload() - { - Unload(); - Main.menuMode = Interface.loadModsID; - } - - internal static bool IsEnabled(string modFile) - { - string enablePath = Path.ChangeExtension(modFile, "enabled"); - return !File.Exists(enablePath) || File.ReadAllText(enablePath) != "false"; - } - - internal static void SetModActive(string modFile, bool active) - { - string path = Path.ChangeExtension(modFile, "enabled"); - using(StreamWriter writer = File.CreateText(path)) - { - writer.Write(active ? "true" : "false"); - } - } - - internal static void EnableMod(string modFile) - { - SetModActive(modFile, true); - } - - internal static void DisableMod(string modFile) - { - SetModActive(modFile, false); - } - - internal static string[] FindModSources() - { - Directory.CreateDirectory(ModSourcePath); - return Directory.GetDirectories(ModSourcePath, "*", SearchOption.TopDirectoryOnly).Where(dir => dir != ".vs").ToArray(); - } - - internal static void BuildAllMods() - { - ThreadPool.QueueUserWorkItem(new WaitCallback(do_BuildAllMods), 1); - } - - internal static void do_BuildAllMods(object threadContext) - { - string[] modFolders = FindModSources(); - int num = 0; - bool flag = false; - foreach(string modFolder in modFolders) - { - Interface.buildMod.SetProgress(num, modFolders.Length); - modToBuild = modFolder; - if(!do_BuildMod(threadContext)) - { - flag = true; - } - num++; - } - Main.menuMode = flag ? Interface.errorMessageID : ( reloadAfterBuild ? Interface.reloadModsID : 0); - } - - internal static void BuildMod() - { - Interface.buildMod.SetProgress(0, 1); - ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object threadContext) { do_BuildMod(threadContext); }), 1); - } - - internal static bool do_BuildMod(object threadContext) - { - Interface.buildMod.SetReading(); - BuildProperties properties = ReadBuildProperties(modToBuild); - if(properties == null) - { - if(!buildAll) - { - Main.menuMode = Interface.errorMessageID; - } - return false; - } - LoadReferences(); - Interface.buildMod.SetCompiling(); - if (!CompileMod(modToBuild, properties)) - { - if (!buildAll) - { - Main.menuMode = Interface.errorMessageID; - } - return false; - } - Interface.buildMod.SetBuildText(); - byte[] propertiesData = PropertiesToBytes(properties); - string file = ModPath + Path.DirectorySeparatorChar + Path.GetFileName(modToBuild) + ".tmod"; - byte[] buffer = File.ReadAllBytes(file); - using(FileStream fileStream = File.Create(file)) - { - using(BinaryWriter writer = new BinaryWriter(fileStream)) - { - writer.Write(propertiesData.Length); - writer.Write(propertiesData); - writer.Write(buffer.Length); - writer.Write(buffer); - string[] images = Directory.GetFiles(modToBuild, "*.png", SearchOption.AllDirectories); - foreach (string image in images) - { - string texturePath = image.Replace(ModSourcePath + Path.DirectorySeparatorChar, null); - texturePath = Path.ChangeExtension(texturePath.Replace(Path.DirectorySeparatorChar, '/'), null); - buffer = File.ReadAllBytes(image); - writer.Write(texturePath); - writer.Write(buffer.Length); - writer.Write(buffer); - } - writer.Write("end"); - } - } - EnableMod(file); - if (!buildAll) - { - Main.menuMode = reloadAfterBuild ? Interface.reloadModsID : 0; - } - return true; - } - - private static BuildProperties ReadBuildProperties(string modDir) - { - string propertiesFile = modDir + Path.DirectorySeparatorChar + "build.txt"; - BuildProperties properties = new BuildProperties(); - if(!File.Exists(propertiesFile)) - { - return properties; - } - string[] lines = File.ReadAllLines(propertiesFile); - foreach (string line in lines) - { - if(line.Length == 0) - { - continue; - } - int split = line.IndexOf('='); - string property = line.Substring(0, split).Trim(); - string value = line.Substring(split + 1).Trim(); - if(value.Length == 0) - { - continue; - } - switch (property) - { - case "dllReferences": - string[] dllReferences = value.Split(','); - for (int k = 0; k < dllReferences.Length; k++) - { - string dllReference = dllReferences[k].Trim(); - if (dllReference.Length > 0) - { - dllReferences[k] = dllReference; - } - } - properties.dllReferences = dllReferences; - break; - case "modReferences": - string[] modReferences = value.Split(','); - for (int k = 0; k < modReferences.Length; k++) - { - string modReference = modReferences[k].Trim(); - if (modReference.Length > 0) - { - modReferences[k] = modReference; - } - } - properties.modReferences = modReferences; - break; - case "author": - properties.author = value; - break; - case "version": - properties.version = value; - break; - case "displayName": - properties.displayName = value; - break; - } - } - foreach(string modReference in properties.modReferences) - { - string path = ModPath + Path.DirectorySeparatorChar + modReference + ".tmod"; - if(!File.Exists(path)) - { - ErrorLogger.LogModReferenceError(modReference); - return null; - } - byte[] data; - using(FileStream fileStream = File.OpenRead(path)) - { - using(BinaryReader reader = new BinaryReader(fileStream)) - { - fileStream.Seek(reader.ReadInt32(), SeekOrigin.Current); - data = reader.ReadBytes(reader.ReadInt32()); - } - } - using (FileStream writeStream = File.Create(ModSourcePath + Path.DirectorySeparatorChar + modReference + ".dll")) - { - using (BinaryWriter writer = new BinaryWriter(writeStream)) - { - writer.Write(data); - } - } - } - return properties; - } - - private static byte[] PropertiesToBytes(BuildProperties properties) - { - byte[] data; - using(MemoryStream memoryStream = new MemoryStream()) - { - using(BinaryWriter writer = new BinaryWriter(memoryStream)) - { - if(properties.dllReferences.Length > 0) - { - writer.Write("dllReferences"); - foreach(string reference in properties.dllReferences) - { - writer.Write(reference); - } - writer.Write(""); - } - if(properties.modReferences.Length > 0) - { - writer.Write("modReferences"); - foreach(string reference in properties.modReferences) - { - writer.Write(reference); - } - writer.Write(""); - } - if(properties.author.Length > 0) - { - writer.Write("author"); - writer.Write(properties.author); - } - if(properties.version.Length > 0) - { - writer.Write("version"); - writer.Write(properties.version); - } - if(properties.displayName.Length > 0) - { - writer.Write("displayName"); - writer.Write(properties.displayName); - } - writer.Write(""); - writer.Flush(); - data = memoryStream.ToArray(); - } - } - return data; - } - - private static bool CompileMod(string modDir, BuildProperties properties) - { - CompilerParameters compileOptions = new CompilerParameters(); - compileOptions.GenerateExecutable = false; - compileOptions.GenerateInMemory = false; - compileOptions.OutputAssembly = ModPath + Path.DirectorySeparatorChar + Path.GetFileName(modDir) + ".tmod"; - foreach(string reference in buildReferences) - { - compileOptions.ReferencedAssemblies.Add(reference); - } - Directory.CreateDirectory(DllPath); - foreach(string reference in properties.dllReferences) - { - compileOptions.ReferencedAssemblies.Add(DllPath + Path.DirectorySeparatorChar + reference + ".dll"); - } - foreach(string reference in properties.modReferences) - { - compileOptions.ReferencedAssemblies.Add(ModSourcePath + Path.DirectorySeparatorChar + reference + ".dll"); - } - - CodeDomProvider codeProvider = new CSharpCodeProvider(); - CompilerResults results = codeProvider.CompileAssemblyFromFile(compileOptions, Directory.GetFiles(modDir, "*.cs", SearchOption.AllDirectories)); - CompilerErrorCollection errors = results.Errors; - foreach(string reference in properties.modReferences) - { - File.Delete(ModSourcePath + Path.DirectorySeparatorChar + reference + ".dll"); - } - if(errors.HasErrors) - { - ErrorLogger.LogCompileErrors(errors); - return false; - } - return true; - } - - public static Texture2D GetTexture(string name) - { - if(!textures.ContainsKey(name)) - { - throw new ArgumentException("Missing texture " + name); - } - return textures[name]; - } - - private static void AddCraftGroups() - { - foreach(Mod mod in mods.Values) - { - try - { - mod.AddCraftGroups(); - } - catch - { - DisableMod(mod.file); - throw; - } - } - } - - //place near end of Terraria.Recipe.SetupRecipes before material checks - internal static void AddRecipes() - { - foreach(Mod mod in mods.Values) - { - try - { - mod.AddRecipes(); - foreach(ModItem item in mod.items.Values) - { - item.AddRecipes(); - } - } - catch - { - DisableMod(mod.file); - throw; - } - } - } -}} \ No newline at end of file diff --git a/Terraria.ModLoader/ModNPC.cs b/Terraria.ModLoader/ModNPC.cs deleted file mode 100644 index 02032717913..00000000000 --- a/Terraria.ModLoader/ModNPC.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Terraria.ModLoader { -public class ModNPC -{ - //add modNPC property to Terraria.NPC (internal set) - //set modNPC to null at beginning of Terraria.NPC.SetDefaults - public NPC npc - { - get; - internal set; - } - public Mod mod - { - get; - internal set; - } - internal string texture; - public ModNPC() - { - npc = new NPC(); - } - - public virtual bool Autoload(ref string name, ref string texture) - { - return mod.Properties.Autoload; - } - - internal void SetupNPC(NPC npc) - { - ModNPC newNPC = (ModNPC)Activator.CreateInstance(GetType()); - newNPC.npc = npc; - npc.modNPC = newNPC; - newNPC.mod = mod; - newNPC.SetDefaults(); - } - - public virtual void SetDefaults() { } -}} diff --git a/Terraria.ModLoader/ModProjectile.cs b/Terraria.ModLoader/ModProjectile.cs deleted file mode 100644 index 57c63c2abb3..00000000000 --- a/Terraria.ModLoader/ModProjectile.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using Terraria; - -namespace Terraria.ModLoader { -public class ModProjectile -{ - //add modProjectile property to Terraria.Projectile (internal set) - //set modProjectile to null at beginning of Terraria.Projectile.SetDefaults - public Projectile projectile - { - get; - internal set; - } - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - internal string texture; - public ModProjectile() - { - projectile = new Projectile(); - projectile.modProjectile = this; - } - - public virtual bool Autoload(ref string name, ref string texture) - { - return mod.Properties.Autoload; - } - - internal void SetupProjectile(Projectile projectile) - { - ModProjectile newProjectile = (ModProjectile)Activator.CreateInstance(GetType()); - newProjectile.projectile = projectile; - projectile.modProjectile = newProjectile; - newProjectile.mod = mod; - newProjectile.SetDefaults(); - } - - public virtual void SetDefaults() { } -}} diff --git a/Terraria.ModLoader/ModProperties.cs b/Terraria.ModLoader/ModProperties.cs deleted file mode 100644 index 59292e66db8..00000000000 --- a/Terraria.ModLoader/ModProperties.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Terraria.ModLoader { -public struct ModProperties -{ - public bool Autoload; -}} diff --git a/Terraria.ModLoader/ModRecipe.cs b/Terraria.ModLoader/ModRecipe.cs deleted file mode 100644 index e6745a9e9fd..00000000000 --- a/Terraria.ModLoader/ModRecipe.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using Terraria; - -namespace Terraria.ModLoader { -public class ModRecipe : Recipe -{ - public readonly Mod mod; - internal readonly IList craftGroups = new List(); - private int numIngredients = 0; - private int numTiles = 0; - public int RecipeIndex - { - get; - private set; - } - - public ModRecipe(Mod mod) - { - this.mod = mod; - } - - public void SetResult(int itemID, int stack = 1) - { - this.createItem.SetDefaults(itemID, false); - this.createItem.stack = stack; - } - - public void SetResult(string itemName, int stack = 1) - { - this.createItem.SetDefaults(itemName); - this.createItem.stack = stack; - } - - public void SetResult(Mod mod, string itemName, int stack = 1) - { - if(mod == null) - { - mod = this.mod; - } - this.SetResult(mod.ItemType(itemName), stack); - } - - public void SetResult(ModItem item, int stack = 1) - { - this.SetResult(item.item.type, stack); - } - - public void AddIngredient(int itemID, int stack = 1) - { - this.requiredItem[numIngredients].SetDefaults(itemID, false); - this.requiredItem[numIngredients].stack = stack; - numIngredients++; - } - - public void AddIngredient(string itemName, int stack = 1) - { - this.requiredItem[numIngredients].SetDefaults(itemName); - this.requiredItem[numIngredients].stack = stack; - numIngredients++; - } - - public void AddIngredient(Mod mod, string itemName, int stack = 1) - { - if(mod == null) - { - mod = this.mod; - } - this.AddIngredient(mod.ItemType(itemName), stack); - } - - public void AddIngredient(ModItem item, int stack = 1) - { - this.AddIngredient(item.item.type, stack); - } - - public void AddCraftGroup(CraftGroup group, int stack = 1) - { - this.AddIngredient(group.Items[0], stack); - this.craftGroups.Add(group); - } - - public void AddCraftGroup(Mod mod, string name, int stack = 1) - { - if(mod == null) - { - mod = this.mod; - } - this.AddCraftGroup(mod.GetCraftGroup(name), stack); - } - - public void AddTile(int tileID) - { - this.requiredTile[numTiles] = tileID; - numTiles++; - } - - public void AddTile(Mod mod, string tileName) - { - if(mod == null) - { - mod = this.mod; - } - this.AddTile(mod.TileType(tileName)); - } - - public void AddTile(ModTile tile) - { - this.AddTile(tile.Type); - } - - //in Terraria.Recipe.Create before alchemy table check add - // ModRecipe modRecipe = this as ModRecipe; - // if(modRecipe != null) { num = modRecipe.ConsumeItem(item.type, item.stack); } - public virtual int ConsumeItem(int type, int numRequired) - { - return numRequired; - } - - //for Terraria.Recipe add public bool ItemMatches(Item invItem, Item reqItem) - //replace || chains with Terraria.Recipe.ItemMatches - //add this to the || chain in Terraria.Recipe.ItemMatches - public bool UseCraftGroup(int invType, int reqType) - { - foreach(CraftGroup group in craftGroups) - { - if(group.Items.Contains(invType) && group.Items.Contains(reqType)) - { - return true; - } - } - return false; - } - - //add to craft group tooltip in Terraria.Main.DrawInventory - public void CraftGroupDisplayName(int reqIndex) - { - foreach(CraftGroup group in craftGroups) - { - if(group.Items.Contains(requiredItem[reqIndex].type)) - { - Main.toolTip.name = group.DisplayName; - return; - } - } - } - - public void AddRecipe() - { - for(int k = 0; k < Recipe.maxRequirements; k++) - { - if(this.requiredTile[k] == 13) - { - this.alchemy = true; - break; - } - } - if(Recipe.numRecipes >= Recipe.maxRecipes) - { - Recipe.maxRecipes += 500; - Array.Resize(ref Main.recipe, Recipe.maxRecipes); - Array.Resize(ref Main.availableRecipe, Recipe.maxRecipes); - Array.Resize(ref Main.availableRecipeY, Recipe.maxRecipes); - for(int k = Recipe.numRecipes; k < Recipe.maxRecipes; k++) - { - Main.recipe[k] = new Recipe(); - Main.availableRecipeY[k] = 65f * k; - } - } - Main.recipe[Recipe.numRecipes] = this; - this.RecipeIndex = Recipe.numRecipes; - mod.recipes.Add(this); - Recipe.numRecipes++; - } -}} \ No newline at end of file diff --git a/Terraria.ModLoader/ModTile.cs b/Terraria.ModLoader/ModTile.cs deleted file mode 100644 index b57bd204066..00000000000 --- a/Terraria.ModLoader/ModTile.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; - -namespace Terraria.ModLoader{ -public class ModTile -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - public ushort Type - { - get; - internal set; - } - internal string texture; - - public int soundType = 0; - public int soundStyle = 1; - public int dustType = 0; - public int drop = 0; - public int animationFrameHeight = 0; - public Color? mapColor = null; - public string mapName = ""; - public float mineResist = 1f; - public int minPick = 0; - public int[] adjTiles = new int[0]; - public int closeDoorID = -1; - public int openDoorID = -1; - public string chest = ""; - public bool bed = false; - - public void AddToArray(ref int[] array) - { - Array.Resize(ref array, array.Length + 1); - array[array.Length - 1] = Type; - } - - public virtual bool Autoload(ref string name, ref string texture) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults() { } - - public virtual bool KillSound(int i, int j) - { - return true; - } - - public virtual void NumDust(int i, int j, bool fail, ref int num) { } - - public virtual bool CreateDust(int i, int j, ref int type) - { - type = dustType; - return true; - } - - public virtual void DropCritterChance(int i, int j, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance) { } - - public virtual bool Drop(int i, int j) - { - return true; - } - - public virtual bool CanKillTile(int i, int j, ref bool blockDamaged) - { - return true; - } - - public virtual void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) { } - - public virtual void KillMultiTile(int i, int j, int frameX, int frameY) { } - - public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { } - - public virtual void SetSpriteEffects(int i, int j, ref SpriteEffects spriteEffects) { } - - public virtual void AnimateTile(ref int frame, ref int frameCounter) { } - - public virtual bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - return true; - } - - public virtual void PostDraw(int i, int j, SpriteBatch spriteBatch) { } - - public virtual Color? MapColor(int i, int j) - { - return mapColor; - } - - public virtual string MapName(int frameX, int frameY) - { - return mapName; - } - - public virtual void RandomUpdate(int i, int j) { } - - public virtual bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - return true; - } - - public virtual bool CanPlace(int i, int j) - { - return true; - } - - public virtual void RightClick(int i, int j) { } - - public virtual void MouseOver(int i, int j) { } - - public virtual void HitWire(int i, int j) { } - - public virtual bool Slope(int i, int j) - { - return true; - } -}} diff --git a/Terraria.ModLoader/ModWall.cs b/Terraria.ModLoader/ModWall.cs deleted file mode 100644 index 1955efe0cc7..00000000000 --- a/Terraria.ModLoader/ModWall.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; - -namespace Terraria.ModLoader { -public class ModWall -{ - public Mod mod - { - get; - internal set; - } - public string Name - { - get; - internal set; - } - public ushort Type - { - get; - internal set; - } - internal string texture; - - public int soundType = 0; - public int soundStyle = 1; - public int dustType = 0; - public int drop = 0; - public Color? mapColor = null; - public string mapName = ""; - - public virtual bool Autoload(ref string name, ref string texture) - { - return mod.Properties.Autoload; - } - - public virtual void SetDefaults() { } - - public virtual bool KillSound(int i, int j) - { - return true; - } - - public virtual void NumDust(int i, int j, bool fail, ref int num) { } - - public virtual bool CreateDust(int i, int j, ref int type) - { - type = dustType; - return true; - } - - public virtual bool Drop(int i, int j, ref int type) - { - type = drop; - return true; - } - - public virtual void KillWall(int i, int j, ref bool fail) { } - - public virtual Color? MapColor(int i, int j) - { - return mapColor; - } - - public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { } - - public virtual void RandomUpdate(int i, int j) { } - - public virtual void AnimateWall(ref byte frame, ref byte frameCounter) { } - - public virtual bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - return true; - } - - public virtual void PostDraw(int i, int j, SpriteBatch spriteBatch) { } -}} diff --git a/Terraria.ModLoader/NPCLoader.cs b/Terraria.ModLoader/NPCLoader.cs deleted file mode 100644 index bc90ad50e8e..00000000000 --- a/Terraria.ModLoader/NPCLoader.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; - -namespace Terraria.ModLoader { -public static class NPCLoader -{ - private static int nextNPC = NPCID.Count; - internal static readonly IDictionary npcs = new Dictionary(); - internal static readonly IList globalNPCs = new List(); - private static int vanillaSkeletonCount = NPCID.Sets.Skeletons.Count; - - internal static int ReserveNPCID() - { - int reserveID = nextNPC; - nextNPC++; - return reserveID; - } - - internal static int NPCCount() - { - return nextNPC; - } - - public static ModNPC GetNPC(int type) - { - if(npcs.ContainsKey(type)) - { - return npcs[type]; - } - else - { - return null; - } - } - - //change initial size of Terraria.Player.npcTypeNoAggro to NPCLoader.NPCCount() - //in Terraria.Main.DrawNPCs and Terraria.NPC.NPCLoot remove type too high check - internal static void ResizeArrays() - { - Array.Resize(ref Main.NPCLoaded, nextNPC); - Array.Resize(ref Main.nextNPC, nextNPC); - Array.Resize(ref Main.slimeRainNPC, nextNPC); - Array.Resize(ref Main.npcTexture, nextNPC); - Array.Resize(ref Main.npcCatchable, nextNPC); - Array.Resize(ref Main.npcName, nextNPC); - Array.Resize(ref Main.npcFrameCount, nextNPC); - Array.Resize(ref NPC.killCount, nextNPC); - Array.Resize(ref NPCID.Sets.NeedsExpertScaling, nextNPC); - Array.Resize(ref NPCID.Sets.ProjectileNPC, nextNPC); - Array.Resize(ref NPCID.Sets.SavesAndLoads, nextNPC); - Array.Resize(ref NPCID.Sets.TrailCacheLength, nextNPC); - Array.Resize(ref NPCID.Sets.MPAllowedEnemies, nextNPC); - Array.Resize(ref NPCID.Sets.TownCritter, nextNPC); - Array.Resize(ref NPCID.Sets.FaceEmote, nextNPC); - Array.Resize(ref NPCID.Sets.ExtraFramesCount, nextNPC); - Array.Resize(ref NPCID.Sets.AttackFrameCount, nextNPC); - Array.Resize(ref NPCID.Sets.DangerDetectRange, nextNPC); - Array.Resize(ref NPCID.Sets.AttackTime, nextNPC); - Array.Resize(ref NPCID.Sets.AttackAverageChance, nextNPC); - Array.Resize(ref NPCID.Sets.AttackType, nextNPC); - Array.Resize(ref NPCID.Sets.PrettySafe, nextNPC); - Array.Resize(ref NPCID.Sets.MagicAuraColor, nextNPC); - Array.Resize(ref NPCID.Sets.BossHeadTextures, nextNPC); - Array.Resize(ref NPCID.Sets.ExcludedFromDeathTally, nextNPC); - Array.Resize(ref NPCID.Sets.TechnicallyABoss, nextNPC); - Array.Resize(ref NPCID.Sets.MustAlwaysDraw, nextNPC); - for(int k = NPCID.Count; k < nextNPC; k++) - { - Main.NPCLoaded[k] = true; - Main.npcFrameCount[k] = 1; - NPCID.Sets.TrailCacheLength[k] = 10; - NPCID.Sets.DangerDetectRange[k] = -1; - NPCID.Sets.AttackTime[k] = -1; - NPCID.Sets.AttackAverageChance[k] = 1; - NPCID.Sets.AttackType[k] = -1; - NPCID.Sets.PrettySafe[k] = -1; - NPCID.Sets.MagicAuraColor[k] = Color.White; - NPCID.Sets.BossHeadTextures[k] = -1; - } - } - - internal static void Unload() - { - npcs.Clear(); - nextNPC = NPCID.Count; - globalNPCs.Clear(); - while(NPCID.Sets.Skeletons.Count > vanillaSkeletonCount) - { - NPCID.Sets.Skeletons.RemoveAt(NPCID.Sets.Skeletons.Count - 1); - } - } - - internal static bool IsModNPC(NPC npc) - { - return npc.type >= NPCID.Count; - } - - //in Terraria.NPC.SetDefaults after if else setting properties call NPCLoader.SetupNPC(this); - //in Terraria.NPC.SetDefaults move Lang stuff before SetupNPC - internal static void SetupNPC(NPC npc) - { - if(IsModNPC(npc)) - { - GetNPC(npc.type).SetupNPC(npc); - } - foreach(GlobalNPC globalNPC in globalNPCs) - { - globalNPC.SetDefaults(npc); - } - } - - //in Terraria.NPC.NPCLoot after hardmode meteor head check add - // if(!NPCLoader.PreNPCLoot(this)) { return; } - internal static bool PreNPCLoot(NPC npc) - { - foreach(GlobalNPC globalNPC in globalNPCs) - { - if(!globalNPC.PreNPCLoot(npc)) - { - return false; - } - } - return true; - } - - //in Terraria.NPC.NPCLoot before heart and star drops add NPCLoader.NPCLoot(this); - internal static void NPCLoot(NPC npc) - { - foreach(GlobalNPC globalNPC in globalNPCs) - { - globalNPC.NPCLoot(npc); - } - } -}} diff --git a/Terraria.ModLoader/ProjectileLoader.cs b/Terraria.ModLoader/ProjectileLoader.cs deleted file mode 100644 index f0edaac4e4d..00000000000 --- a/Terraria.ModLoader/ProjectileLoader.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using Terraria; -using Terraria.ID; - -namespace Terraria.ModLoader { -public static class ProjectileLoader -{ - private static int nextProjectile = ProjectileID.Count; - internal static readonly IDictionary projectiles = new Dictionary(); - internal static readonly IList globalProjectiles = new List(); - - internal static int ReserveProjectileID() - { - int reserveID = nextProjectile; - nextProjectile++; - return reserveID; - } - - internal static int ProjectileCount() - { - return nextProjectile; - } - - public static ModProjectile GetProjectile(int type) - { - if(projectiles.ContainsKey(type)) - { - return projectiles[type]; - } - else - { - return null; - } - } - - //change initial size of Terraria.Player.ownedProjectileCounts to ProjectileLoader.ProjectileCount() - internal static void ResizeArrays() - { - Array.Resize(ref Main.projectileLoaded, nextProjectile); - Array.Resize(ref Main.projectileTexture, nextProjectile); - Array.Resize(ref Main.projHostile, nextProjectile); - Array.Resize(ref Main.projHook, nextProjectile); - Array.Resize(ref Main.projFrames, nextProjectile); - Array.Resize(ref Main.projPet, nextProjectile); - Array.Resize(ref ProjectileID.Sets.TrailingMode, nextProjectile); - Array.Resize(ref ProjectileID.Sets.TrailCacheLength, nextProjectile); - Array.Resize(ref ProjectileID.Sets.LightPet, nextProjectile); - Array.Resize(ref ProjectileID.Sets.Homing, nextProjectile); - Array.Resize(ref ProjectileID.Sets.MinionSacrificable, nextProjectile); - Array.Resize(ref ProjectileID.Sets.DontAttachHideToAlpha, nextProjectile); - Array.Resize(ref ProjectileID.Sets.NeedsUUID, nextProjectile); - Array.Resize(ref ProjectileID.Sets.StardustDragon, nextProjectile); - for(int k = ProjectileID.Count; k < nextProjectile; k++) - { - Main.projectileLoaded[k] = true; - Main.projFrames[k] = 1; - ProjectileID.Sets.TrailingMode[k] = -1; - ProjectileID.Sets.TrailCacheLength[k] = 10; - } - } - - internal static void Unload() - { - projectiles.Clear(); - nextProjectile = ProjectileID.Count; - globalProjectiles.Clear(); - } - - internal static bool IsModProjectile(Projectile projectile) - { - return projectile.type >= ProjectileID.Count; - } - - //in Terraria.Projectile.SetDefaults get rid of bad type check - //in Terraria.Projectile.SetDefaults before scaling size call ProjectileLoader.SetupProjectile(this); - internal static void SetupProjectile(Projectile projectile) - { - if(IsModProjectile(projectile)) - { - GetProjectile(projectile.type).SetupProjectile(projectile); - } - foreach(GlobalProjectile globalProjectile in globalProjectiles) - { - globalProjectile.SetDefaults(projectile); - } - } -}} diff --git a/Terraria.ModLoader/TileLoader.cs b/Terraria.ModLoader/TileLoader.cs deleted file mode 100644 index 41a3d668707..00000000000 --- a/Terraria.ModLoader/TileLoader.cs +++ /dev/null @@ -1,1010 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Enums; -using Terraria.ID; -using Terraria.Map; -using Terraria.ObjectData; - -namespace Terraria.ModLoader { -public static class TileLoader -{ - //make Terraria.ObjectData.TileObjectData._data internal - //make all static Terraria.ObjectData.TileObjectData.StyleName fields public - //make Terraria.ObjectData.TileObjectData.LinkedAlternates public - //make Terraria.ObjectData.TileObjectData.SubTiles and Alternates internal - //at end of Terraria.ObjectData.TileObjectData.Initialize remove TileObjectData.readOnlyData = true; - //at beginning of Terraria.WorldGen.PlaceTile remove type too high check - //at beginning of Terraria.WorldGen.PlaceObject remove type too high check - //in Terraria.WorldGen.Convert remove type too high checks - //in Terraria.WorldGen.StartRoomCheck change 419 to WorldGen.houseTile.Length - //at end of Terraria.WorldGen.KillWall remove type too high check - //in Terraria.Player change adjTile and oldAdjTile size to TileLoader.TileCount() - //in Terraria.Player.AdjTiles change 419 to adjTile.Length - //in Terraria.Lighting for accOreFinder replace 419 with Main.tileValue.Length - //make Terraria.WorldGen public - - //in Terraria.IO.WorldFile.SaveFileFormatHeader set initial num to TileLoader.TileCount - private static int nextTile = TileID.Count; - internal static readonly IDictionary tiles = new Dictionary(); - internal static readonly IList globalTiles = new List(); - private static bool loaded = false; - private static int vanillaChairCount = TileID.Sets.RoomNeeds.CountsAsChair.Length; - private static int vanillaTableCount = TileID.Sets.RoomNeeds.CountsAsTable.Length; - private static int vanillaTorchCount = TileID.Sets.RoomNeeds.CountsAsTorch.Length; - private static int vanillaDoorCount = TileID.Sets.RoomNeeds.CountsAsDoor.Length; - - internal static int ReserveTileID() - { - int reserveID = nextTile; - nextTile++; - return reserveID; - } - - internal static int TileCount() - { - return nextTile; - } - - public static ModTile GetTile(int type) - { - if(tiles.ContainsKey(type)) - { - return tiles[type]; - } - else - { - return null; - } - } - - private static void Resize2DArray(ref T[,] array, int newSize) - { - int dim1 = array.GetLength(0); - int dim2 = array.GetLength(1); - T[,] newArray = new T[newSize, dim2]; - for(int j = 0; j < newSize && j < dim1; j++) - { - for(int k = 0; k < dim2; k++) - { - newArray[j, k] = array[j, k]; - } - } - array = newArray; - } - - internal static void ResizeArrays(bool unloading = false) - { - Array.Resize(ref Main.tileSetsLoaded, nextTile); - for(int k = TileID.Count; k < nextTile; k++) - { - Main.tileSetsLoaded[k] = true; - } - Resize2DArray(ref Main.tileAltTexture, nextTile); - Resize2DArray(ref Main.tileAltTextureInit, nextTile); - Resize2DArray(ref Main.tileAltTextureDrawn, nextTile); - Array.Resize(ref Main.tileTexture, nextTile); - Array.Resize(ref Main.tileLighted, nextTile); - Array.Resize(ref Main.tileMergeDirt, nextTile); - Array.Resize(ref Main.tileCut, nextTile); - Array.Resize(ref Main.tileAlch, nextTile); - Array.Resize(ref Main.tileShine, nextTile); - Array.Resize(ref Main.tileShine2, nextTile); - Array.Resize(ref Main.tileStone, nextTile); - Array.Resize(ref Main.tileAxe, nextTile); - Array.Resize(ref Main.tileHammer, nextTile); - Array.Resize(ref Main.tileWaterDeath, nextTile); - Array.Resize(ref Main.tileLavaDeath, nextTile); - Array.Resize(ref Main.tileTable, nextTile); - Array.Resize(ref Main.tileBlockLight, nextTile); - Array.Resize(ref Main.tileNoSunLight, nextTile); - Array.Resize(ref Main.tileDungeon, nextTile); - Array.Resize(ref Main.tileSpelunker, nextTile); - Array.Resize(ref Main.tileSolidTop, nextTile); - Array.Resize(ref Main.tileSolid, nextTile); - Array.Resize(ref Main.tileBouncy, nextTile); - Array.Resize(ref Main.tileValue, nextTile); - Array.Resize(ref Main.tileLargeFrames, nextTile); - Array.Resize(ref Main.tileRope, nextTile); - Array.Resize(ref Main.tileBrick, nextTile); - Array.Resize(ref Main.tileMoss, nextTile); - Array.Resize(ref Main.tileNoAttach, nextTile); - Array.Resize(ref Main.tileNoFail, nextTile); - Array.Resize(ref Main.tileObsidianKill, nextTile); - Array.Resize(ref Main.tileFrameImportant, nextTile); - Array.Resize(ref Main.tilePile, nextTile); - Array.Resize(ref Main.tileBlendAll, nextTile); - Array.Resize(ref Main.tileGlowMask, nextTile); - Array.Resize(ref Main.tileContainer, nextTile); - Array.Resize(ref Main.tileSign, nextTile); - Array.Resize(ref Main.tileMerge, nextTile); - for(int k = 0; k < nextTile; k++) //oh dear - { - Array.Resize(ref Main.tileMerge[k], nextTile); - } - Array.Resize(ref Main.tileSand, nextTile); - Array.Resize(ref Main.tileFlame, nextTile); - Array.Resize(ref Main.tileFrame, nextTile); - Array.Resize(ref Main.tileFrameCounter, nextTile); - Array.Resize(ref WorldGen.tileCounts, nextTile); - Array.Resize(ref WorldGen.houseTile, nextTile); - Array.Resize(ref MapHelper.tileLookup, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Grass, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Stone, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Ice, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Sand, nextTile); - Array.Resize(ref TileID.Sets.Conversion.HardenedSand, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Sandstone, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Thorn, nextTile); - Array.Resize(ref TileID.Sets.Conversion.Moss, nextTile); - Array.Resize(ref TileID.Sets.AllTiles, nextTile); - for(int k = TileID.Count; k < nextTile; k++) - { - TileID.Sets.AllTiles[k] = true; - } - Array.Resize(ref TileID.Sets.Mud, nextTile); - Array.Resize(ref TileID.Sets.Snow, nextTile); - Array.Resize(ref TileID.Sets.Ices, nextTile); - Array.Resize(ref TileID.Sets.IcesSlush, nextTile); - Array.Resize(ref TileID.Sets.IcesSnow, nextTile); - Array.Resize(ref TileID.Sets.GrassSpecial, nextTile); - Array.Resize(ref TileID.Sets.JungleSpecial, nextTile); - Array.Resize(ref TileID.Sets.HellSpecial, nextTile); - Array.Resize(ref TileID.Sets.Leaves, nextTile); - Array.Resize(ref TileID.Sets.GeneralPlacementTiles, nextTile); - Array.Resize(ref TileID.Sets.CanBeClearedDuringGeneration, nextTile); - Array.Resize(ref TileID.Sets.Corrupt, nextTile); - Array.Resize(ref TileID.Sets.Hallow, nextTile); - Array.Resize(ref TileID.Sets.Crimson, nextTile); - Array.Resize(ref TileID.Sets.BlocksStairs, nextTile); - Array.Resize(ref TileID.Sets.BlocksStairsAbove, nextTile); - Array.Resize(ref TileID.Sets.NotReallySolid, nextTile); - Array.Resize(ref TileID.Sets.ChecksForMerge, nextTile); - Array.Resize(ref TileID.Sets.FramesOnKillWall, nextTile); - Array.Resize(ref TileID.Sets.AvoidedByNPCs, nextTile); - Array.Resize(ref TileID.Sets.InteractibleByNPCs, nextTile); - Array.Resize(ref TileID.Sets.HousingWalls, nextTile); - Array.Resize(ref TileID.Sets.BreakableWhenPlacing, nextTile); - Array.Resize(ref TileID.Sets.TouchDamageVines, nextTile); - Array.Resize(ref TileID.Sets.TouchDamageSands, nextTile); - Array.Resize(ref TileID.Sets.TouchDamageHot, nextTile); - Array.Resize(ref TileID.Sets.TouchDamageOther, nextTile); - Array.Resize(ref TileID.Sets.Falling, nextTile); - Array.Resize(ref TileID.Sets.Ore, nextTile); - while(TileObjectData._data.Count < nextTile) - { - TileObjectData._data.Add(null); - } - if(!unloading) - { - loaded = true; - } - } - - internal static void Unload() - { - loaded = false; - tiles.Clear(); - nextTile = TileID.Count; - globalTiles.Clear(); - Array.Resize(ref TileID.Sets.RoomNeeds.CountsAsChair, vanillaChairCount); - Array.Resize(ref TileID.Sets.RoomNeeds.CountsAsTable, vanillaTableCount); - Array.Resize(ref TileID.Sets.RoomNeeds.CountsAsTorch, vanillaTorchCount); - Array.Resize(ref TileID.Sets.RoomNeeds.CountsAsDoor, vanillaDoorCount); - while(TileObjectData._data.Count > TileID.Count) - { - TileObjectData._data.RemoveAt(TileObjectData._data.Count - 1); - } - } - - private const int magicTableNumber = 12; - - //add to beginning of Terraria.IO.WorldFile.SaveWorldTiles - internal static void WriteTable(BinaryWriter writer) - { - HashSet tiles = new HashSet(); - HashSet walls = new HashSet(); - for(int x = 0; x < Main.maxTilesX; x++) - { - for(int y = 0; y < Main.maxTilesY; y++) - { - ushort type = Main.tile[x, y].type; - if(type >= TileID.Count) - { - tiles.Add(type); - } - type = Main.tile[x, y].wall; - if(type >= WallID.Count) - { - walls.Add(type); - } - } - } - if(tiles.Count == 0 && walls.Count == 0) - { - return; //nothing if there's neither tiles nor walls - } - for(int k = 0; k < magicTableNumber; k++) //all we need to do is write 255 3 times, but it's nice to be safe - { - writer.Write((byte)255); - } - byte identifier; - if(tiles.Count > 0 && walls.Count == 0) - { - identifier = 255; - } - else if(tiles.Count > 0 && walls.Count > 0) - { - identifier = 254; - } - else //tiles.Count == 0 && walls.Count > 0 - { - identifier = 253; - } - writer.Write(identifier); - if(tiles.Count > 0) - { - writer.Write((ushort)tiles.Count); - foreach(ushort type in tiles) - { - writer.Write(type); - ModTile tile = GetTile(type); - writer.Write(tile.mod.Name); - writer.Write(tile.Name); - } - } - if(walls.Count > 0) - { - writer.Write((ushort)walls.Count); - foreach(ushort type in walls) - { - writer.Write(type); - ModWall wall = WallLoader.GetWall(type); - writer.Write(wall.mod.Name); - writer.Write(wall.Name); - } - } - } - - //add to beginning of Terraria.IO.WorldFile.LoadWorldTiles - // IDictionary modTiles = new Dictionary(); - // IDictionary modWalls = new Dictionary(); - // TileLoader.ReadTable(reader, modTiles, modWalls); - //in Terraria.IO.WorldFile.ValidateWorld after baseStream.Position = (long)array2[1]; add - // TileLoader.ReadTable(fileIO, new Dictionary(), new Dictionary()); - internal static void ReadTable(BinaryReader reader, IDictionary tileTable, IDictionary wallTable) - { - long startPos = reader.BaseStream.Position; - for(int k = 0; k < magicTableNumber; k++) - { - if(reader.ReadByte() != (byte)255) - { - reader.BaseStream.Seek(startPos, SeekOrigin.Begin); - return; - } - } - byte identifier = reader.ReadByte(); - if(identifier < (byte)253) - { - return; - } - if(identifier >= 254) - { - ushort count = reader.ReadUInt16(); - for(ushort k = 0; k < count; k++) - { - ushort type = reader.ReadUInt16(); - string modName = reader.ReadString(); - string tileName = reader.ReadString(); - Mod mod = ModLoader.GetMod(modName); - if(mod == null) - { - tileTable[(int)type] = 0; - } - else - { - tileTable[(int)type] = mod.TileType(tileName); - } - } - } - if(identifier <= 254) - { - ushort count = reader.ReadUInt16(); - for(ushort k = 0; k < count; k++) - { - ushort type = reader.ReadUInt16(); - string modName = reader.ReadString(); - string wallname = reader.ReadString(); - Mod mod = ModLoader.GetMod(modName); - if(mod == null) - { - wallTable[(int)type] = 0; - } - else - { - wallTable[(int)type] = mod.WallType(wallname); - } - } - } - } - - //in Terraria.IO.WorldFile.LoadWorldTiles replace tile.type = (ushort)num2; with - // tile.type = TileLoader.ReadTileType(num2, modTiles); - //in Terraria.IO.WorldFile.LoadWorldTiles after if else with importance array add - // num2 = (int)tile.type; - internal static ushort ReadTileType(int type, IDictionary table) - { - if(table.ContainsKey(type)) - { - type = table[type]; - } - return (ushort)type; - } - - //in Terraria.WorldGen.TileFrame after if else chain inside frameImportant if statement before return add - // else { TileLoader.CheckModTile(i, j, num); } - //in Terraria.TileObject.CanPlace add optional checkStay parameter as false to end - // and add && !checkStay to if statement that sets flag4 - internal static void CheckModTile(int i, int j, int type) - { - if(WorldGen.destroyObject) - { - return; - } - TileObjectData tileData = TileObjectData.GetTileData(type, 0, 0); - if(tileData == null) - { - return; - } - int frameX = Main.tile[i, j].frameX; - int frameY = Main.tile[i, j].frameY; - - int subX = frameX / tileData.CoordinateFullWidth; - int subY = frameY / tileData.CoordinateFullHeight; - int wrap = tileData.StyleWrapLimit; - if(wrap == 0) - { - wrap = 1; - } - int subTile = tileData.StyleHorizontal ? subY * wrap + subX : subX * wrap + subY; - int style = subTile / tileData.StyleMultiplier; - int alternate = subTile % tileData.StyleMultiplier; - for(int k = 0; k < tileData.AlternatesCount; k++) - { - if(alternate >= tileData.Alternates[k].Style && alternate <= tileData.Alternates[k].Style + tileData.RandomStyleRange) - { - alternate = k; - break; - } - } - tileData = TileObjectData.GetTileData(type, style, alternate + 1); - - int partFrameX = frameX % tileData.CoordinateFullWidth; - int partFrameY = frameY % tileData.CoordinateFullHeight; - int partX = partFrameX / (tileData.CoordinateWidth + tileData.CoordinatePadding); - int partY = 0; - int remainingFrameY = partFrameY; - while(remainingFrameY > 0) - { - remainingFrameY -= tileData.CoordinateHeights[partY] + tileData.CoordinatePadding; - partY++; - } - i -= partX; - j -= partY; - int originX = i + tileData.Origin.X; - int originY = j + tileData.Origin.Y; - - TileObject objectData; - bool partiallyDestroyed = false; - for(int x = i; x < i + tileData.Width; x++) - { - for(int y = j; y < j + tileData.Height; y++) - { - if(!Main.tile[x, y].active() || Main.tile[x, y].type != type) - { - partiallyDestroyed = true; - break; - } - } - if(partiallyDestroyed) - { - break; - } - } - if (partiallyDestroyed || !TileObject.CanPlace(originX, originY, type, style, 0, out objectData, true, true)) - { - WorldGen.destroyObject = true; - for (int x = i; x < i + tileData.Width; x++) - { - for (int y = j; y < j + tileData.Height; y++) - { - if (Main.tile[x, y].type == type && Main.tile[x, y].active()) - { - WorldGen.KillTile(x, y, false, false, false); - } - } - } - KillMultiTile(i, j, frameX - partFrameX, frameY - partFrameY, type); - WorldGen.destroyObject = false; - for (int x = i - 1; x < i + tileData.Width + 2; x++) - { - for (int y = j - 1; y < j + tileData.Height + 2; y++) - { - WorldGen.TileFrame(x, y, false, false); - } - } - } - } - - //in Terraria.WorldGen.OpenDoor replace bad type check with TileLoader.OpenDoorID(Main.tile[i, j]) < 0 - //in Terraria.WorldGen.OpenDoor replace 11 with (ushort)TileLoader.OpenDoorID - //replace all type checks before WorldGen.OpenDoor - internal static int OpenDoorID(Tile tile) - { - ModTile modTile = GetTile(tile.type); - if(modTile != null) - { - return modTile.openDoorID; - } - if(tile.type == TileID.ClosedDoor && (tile.frameX < 594 || tile.frameY > 646)) - { - return TileID.OpenDoor; - } - return -1; - } - - //in Terraria.WorldGen.CloseDoor replace bad type check with TileLoader.CloseDoorID(Main.tile[i, j]) < 0 - //in Terraria.WorldGen.CloseDoor replace 10 with (ushort)TileLoader.CloseDoorID - //replace all type checks before WorldGen.CloseDoor - internal static int CloseDoorID(Tile tile) - { - ModTile modTile = GetTile(tile.type); - if(modTile != null) - { - return modTile.closeDoorID; - } - if(tile.type == TileID.OpenDoor) - { - return TileID.ClosedDoor; - } - return -1; - } - - //replace chest checks (type == 21) with this - internal static bool IsChest(int type) - { - if(type == TileID.Containers) - { - return true; - } - return ModChestName(type).Length > 0; - } - - //in Terraria.UI.ChestUI add this to Lang lookups - internal static string ModChestName(int type) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - return modTile.chest; - } - return ""; - } - - //in Terraria.Player.CheckSpawn add this to bed type check - internal static bool IsModBed(int type) - { - ModTile modTile = GetTile(type); - if(modTile == null) - { - return false; - } - return modTile.bed; - } - - //in Terraria.ObjectData.TileObject data make the following public: - // newTile, newSubTile, newAlternate, addTile, addSubTile, addAlternate - internal static void SetDefaults(ModTile tile) - { - tile.SetDefaults(); - if(Main.tileLavaDeath[tile.Type]) - { - Main.tileObsidianKill[tile.Type] = true; - } - if(Main.tileSolid[tile.Type]) - { - Main.tileNoSunLight[tile.Type] = true; - } - } - - //in Terraria.WorldGen.KillTile inside if (!effectOnly && !WorldGen.stopDrops) for playing sounds - // add if(!TileLoader.KillSound(i, j, tile.type)) { } to beginning of if/else chain and turn first if into else if - internal static bool KillSound(int i, int j, int type) - { - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.KillSound(i, j, type)) - { - return false; - } - } - ModTile modTile = GetTile(type); - if(modTile != null) - { - if(!modTile.KillSound(i, j)) - { - return false; - } - Main.PlaySound(modTile.soundType, i * 16, j * 16, modTile.soundStyle); - return false; - } - return true; - } - - //in Terraria.WorldGen.KillTile before num14 (num dust iteration) is declared, add - // TileLoader.NumDust(i, j, tile.type, ref num13); - internal static void NumDust(int i, int j, int type, bool fail, ref int numDust) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.NumDust(i, j, fail, ref numDust); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.NumDust(i, j, type, fail, ref numDust); - } - } - - //in Terraria.WorldGen.KillTile replace if (num15 >= 0) with - // if(TileLoader.CreateDust(i, j, tile.type, ref num15) && num15 >= 0) - internal static bool CreateDust(int i, int j, int type, ref int dustType) - { - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.CreateDust(i, j, type, ref dustType)) - { - return false; - } - } - ModTile modTile = GetTile(type); - if(modTile != null) - { - return modTile.CreateDust(i, j, ref dustType); - } - return true; - } - - //in Terraria.WorldGen.KillTile before if statement checking num43 call - // TileLoader.DropCritterChance(i, j, tile.type, ref num43, ref num44, ref num45); - internal static void DropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.DropCritterChance(i, j, ref wormChance, ref grassHopperChance, ref jungleGrubChance); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.DropCritterChance(i, j, type, ref wormChance, ref grassHopperChance, ref jungleGrubChance); - } - } - - //in Terraria.WorldGen.KillTile before if statements checking num49 and num50 - // add bool vanillaDrop = TileLoader.Drop(i, j, tile.type); - // add "vanillaDrop && " to beginning of these if statements - internal static bool Drop(int i, int j, int type) - { - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.Drop(i, j, type)) - { - return false; - } - } - ModTile modTile = GetTile(type); - if(modTile != null) - { - if(!modTile.Drop(i, j)) - { - return false; - } - if(modTile.drop > 0) - { - Item.NewItem(i * 16, j * 16, 16, 16, modTile.drop, 1, false, -1, false, false); - } - return false; - } - return true; - } - - //in Terraria.WorldGen.CanKillTile after check for tile.active() add - // if(!TileLoader.CanKillTile(i, j, tile.type, ref blockDamaged)) { return false; } - internal static bool CanKillTile(int i, int j, int type, ref bool blockDamaged) - { - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.CanKillTile(i, j, type, ref blockDamaged)) - { - return false; - } - } - ModTile modTile = GetTile(type); - if(modTile != null) - { - return modTile.CanKillTile(i, j, ref blockDamaged); - } - return true; - } - - //in Terraria.WorldGen.KillTile before if (!effectOnly && !WorldGen.stopDrops) add - // TileLoader.KillTile(i, j, tile.type, ref fail, ref effectOnly, ref noItem); - internal static void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.KillTile(i, j, ref fail, ref effectOnly, ref noItem); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.KillTile(i, j, type, ref fail, ref effectOnly, ref noItem); - } - } - - internal static void KillMultiTile(int i, int j, int frameX, int frameY, int type) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.KillMultiTile(i, j, frameX, frameY); - } - } - - //in Terraria.Lighting.PreRenderPhase after label after if statement checking Main.tileLighted call - // TileLoader.ModifyLight(n, num17, tile.type, ref num18, ref num19, ref num20); - internal static void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) - { - if(!Main.tileLighted[type]) - { - return; - } - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.ModifyLight(i, j, ref r, ref g, ref b); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.ModifyLight(i, j, type, ref r, ref g, ref b); - } - } - - //in Terraria.Main.DrawTiles after if statement setting effects call - // TileLoader.SetSpriteEffects(j, i, type, ref effects); - internal static void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.SetSpriteEffects(i, j, ref spriteEffects); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.SetSpriteEffects(i, j, type, ref spriteEffects); - } - } - - //in Terraria.Main.DrawTiles after if statements setting num11 and num12 call - // TileLoader.SetDrawPositions(tile, ref num9, ref num11, ref num12); - internal static void SetDrawPositions(Tile tile, ref int width, ref int offsetY, ref int height) - { - if(tile.type >= TileID.Count) - { - TileObjectData tileData = TileObjectData.GetTileData(tile.type, 0, 0); - if(tileData != null) - { - int partFrameY = tile.frameY % tileData.CoordinateFullHeight; - int partY = 0; - while (partFrameY > 0) - { - partFrameY -= tileData.CoordinateHeights[partY] + tileData.CoordinatePadding; - partY++; - } - width = tileData.CoordinateWidth; - offsetY = tileData.DrawYOffset; - height = tileData.CoordinateHeights[partY]; - } - } - } - - //in Terraria.Main.Update after vanilla tile animations call TileLoader.AnimateTiles(); - internal static void AnimateTiles() - { - if(loaded) - { - foreach(ModTile modTile in tiles.Values) - { - modTile.AnimateTile(ref Main.tileFrame[modTile.Type], ref Main.tileFrameCounter[modTile.Type]); - } - } - } - - //in Terraria.Main.Draw after small if statements setting num15 call - // TileLoader.SetAnimationFrame(type, ref num15); - internal static void SetAnimationFrame(int type, ref int frameY) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - frameY = modTile.animationFrameHeight * Main.tileFrame[type]; - } - } - - //in Terraria.Main.Draw after calling SetAnimationFrame call - // if(!TileLoader.PreDraw(j, i, type, Main.spriteBatch)) - // { TileLoader.PostDraw(j, i, type, Main.spriteBatch); continue; } - internal static bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.PreDraw(i, j, type, spriteBatch)) - { - return false; - } - } - ModTile modTile = GetTile(type); - if(modTile != null && !modTile.PreDraw(i, j, spriteBatch)) - { - return false; - } - return true; - } - - //in Terraria.Main.Draw after if statement checking whether texture2D is null call - // TileLoader.PostDraw(j, i, type, Main.spriteBatch); - internal static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.PostDraw(i, j, spriteBatch); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.PostDraw(i, j, type, spriteBatch); - } - } - - //add internal int x, internal int y, and internal ushort modType fields to Terraria.Map.MapTile - // change constructor, constructor uses, Equals, EqualsWithoutLight, and Clear to accomodate for this - //at beginning of Terraria.Map.WorldMap.SetTile add tile.x = x; tile.y = y; tile.modType = TileLoader.MapModType(x, y); - //at end of Terraria.Map.MapHelper.CreateMapTile replace return with - // MapTile mapTile = MapTile.Create((ushort)num16, (byte)num2, (byte)num); mapTile.x = i; mapTile.y = j; - // mapTile.modType = TileLoader.MapModType(i, j); - //at end of constructor for Terraria.Map.WorldMap add - // for(int x = 0; x < maxWidth; x++) { for(int y = 0; y < maxHeight; y++) - // { this._tiles[x, y].x = x; this._tiles[x, y].y = y; }} - internal static ushort MapModType(int i, int j) - { - Tile tile = Main.tile[i, j]; - if(tile.active()) - { - if(tile.type >= TileID.Count) - { - return tile.type; - } - } - else if(tile.wall >= WallID.Count) - { - return (ushort)(TileCount() + tile.wall - WallID.Count); - } - return 0; - } - - //in Terraria.Map.MapHelper.GetMapTileXnaColor after result is initialized call - // TileLoader.MapColor(tile, ref result); - internal static void MapColor(MapTile mapTile, ref Color color) - { - Tile tile = Main.tile[mapTile.x, mapTile.y]; - if(tile.active()) - { - ModTile modTile = GetTile(tile.type); - if(modTile != null) - { - Color? modColor = modTile.MapColor(mapTile.x, mapTile.y); - if(modColor.HasValue) - { - color = modColor.Value; - } - } - } - else - { - ModWall modWall = WallLoader.GetWall(tile.wall); - if(modWall != null) - { - Color? modColor = modWall.MapColor(mapTile.x, mapTile.y); - if(modColor.HasValue) - { - color = modColor.Value; - } - } - } - } - - //in Terraria.WorldGen.UpdateWorld in the while loops updating certain numbers of tiles at end of null check if statements - // add TileLoader.RandomUpdate(num7, num8, Main.tile[num7, num8].type; for the first loop - // add TileLoader.RandomUpdate(num64, num65, Main.tile[num64, num65].type; for the second loop - internal static void RandomUpdate(int i, int j, int type) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.RandomUpdate(i, j); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.RandomUpdate(i, j, type); - } - } - - //in Terraria.WorldGen.TileFrame at beginning of block of if(tile.active()) add - // if(!TileLoader.TileFrame(i, j, tile.type, ref resetFrame, ref noBreak)) { return; } - internal static bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) - { - ModTile modTile = GetTile(type); - bool flag = true; - if(modTile != null) - { - flag = modTile.TileFrame(i, j, ref resetFrame, ref noBreak); - } - foreach(GlobalTile globalTile in globalTiles) - { - flag &= globalTile.TileFrame(i, j, type, ref resetFrame, ref noBreak); - } - return flag; - } - - //in Terraria.Player.ItemCheck in if statements for mining - // replace num222 += item.hammer; with TileLoader.MineDamage(item.hammer, ref num222); - // replace num222 += item.axe; with TileLoader.MineDamage(item.axe, ref num222); - //in Terraria.Player.PickTile replace num += pickPower; with TileLoader.MineDamage(pickPower, ref num); - internal static void MineDamage(int minePower, ref int damage) - { - Tile target = Main.tile[Player.tileTargetX, Player.tileTargetY]; - ModTile modTile = GetTile(target.type); - if(modTile != null) - { - damage = (int)(damage + minePower / modTile.mineResist); - } - else - { - damage += minePower; - } - } - - //in Terraria.Player.ItemCheck at end of else if chain setting num to 0 add - // else { TileLoader.PickPowerCheck(tile, pickPower, ref num); } - internal static void PickPowerCheck(Tile target, int pickPower, ref int damage) - { - ModTile modTile = GetTile(target.type); - if(modTile != null && pickPower < modTile.minPick) - { - damage = 0; - } - } - - //in Terraria.Player.PlaceThing after tileObject is initalized add else to if statement and before add - // if(!TileLoader.CanPlace(Player.tileTargetX, Player.tileTargetY)) { } - internal static bool CanPlace(int i, int j) - { - int type = Main.tile[i, j].type; - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.CanPlace(i, j, type)) - { - return false; - } - } - ModTile modTile = GetTile(type); - if(modTile != null && !modTile.CanPlace(i, j)) - { - return false; - } - return true; - } - - //in Terraria.Player.AdjTiles in end of if statement checking for tile's active - // add TileLoader.AdjTiles(this, Main.tile[j, k].type); - internal static void AdjTiles(Player player, int type) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - foreach(int k in modTile.adjTiles) - { - player.adjTile[k] = true; - } - } - foreach(GlobalTile globalTile in globalTiles) - { - int[] adjTiles = globalTile.AdjTiles(type); - foreach(int k in adjTiles) - { - player.adjTile[k] = true; - } - } - } - - //in Terraria.Player.Update in if statements involving controluseTile and releaseUseTile - // at end of type-check if else chain add TileLoader.RightClick(Player.tileTargetX, Player.tileTargetY); - internal static void RightClick(int i, int j) - { - int type = Main.tile[i, j].type; - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.RightClick(i, j); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.RightClick(i, j, type); - } - } - - //in Terraria.Player.Update after if statements setting showItemIcon call - // TileLoader.MouseOver(Player.tileTargetX, Player.tileTargetY); - internal static void MouseOver(int i, int j) - { - int type = Main.tile[i, j].type; - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.MouseOver(i, j); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.MouseOver(i, j, type); - } - } - - //in Terraria.Wiring make the following public: - // _wireList, _toProcess, _teleport, _inPumpX, _inPumpY, _numInPump, _outPumpX, _outPumpY, _numOutPump CheckMech, TripWire - //at end of Terraria.Wiring.HitWireSingle inside if statement checking for tile active add - // TileLoader.HitWire(i, j, type); - internal static void HitWire(int i, int j, int type) - { - ModTile modTile = GetTile(type); - if(modTile != null) - { - modTile.HitWire(i, j); - } - foreach(GlobalTile globalTile in globalTiles) - { - globalTile.HitWire(i, j, type); - } - } - - //in Terraria.Player.ItemCheck in poundRelease if statement before sloping if statements add - // if(TileLoader.Slope(num223, num224, Main.tile[num223, num224].type)) { } else - internal static bool Slope(int i, int j, int type) - { - foreach(GlobalTile globalTile in globalTiles) - { - if(!globalTile.Slope(i, j, type)) - { - return true; - } - } - ModTile modTile = GetTile(type); - if(modTile != null) - { - return !modTile.Slope(i, j); - } - return false; - } -}} diff --git a/Terraria.ModLoader/WallLoader.cs b/Terraria.ModLoader/WallLoader.cs deleted file mode 100644 index a84eb552332..00000000000 --- a/Terraria.ModLoader/WallLoader.cs +++ /dev/null @@ -1,297 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.Map; - -namespace Terraria.ModLoader { -public static class WallLoader -{ - private static int nextWall = WallID.Count; - internal static readonly IDictionary walls = new Dictionary(); - internal static readonly IList globalWalls = new List(); - private static bool loaded = false; - - internal static int ReserveWallID() - { - int reserveID = nextWall; - nextWall++; - return reserveID; - } - - internal static int WallCount() - { - return nextWall; - } - - public static ModWall GetWall(int type) - { - if(walls.ContainsKey(type)) - { - return walls[type]; - } - else - { - return null; - } - } - - private static void Resize2DArray(ref T[,] array, int newSize) - { - int dim1 = array.GetLength(0); - int dim2 = array.GetLength(1); - T[,] newArray = new T[newSize, dim2]; - for (int j = 0; j < newSize && j < dim1; j++) - { - for (int k = 0; k < dim2; k++) - { - newArray[j, k] = array[j, k]; - } - } - array = newArray; - } - - internal static void ResizeArrays(bool unloading = false) - { - Array.Resize(ref Main.wallLoaded, nextWall); - for (int k = WallID.Count; k < nextWall; k++) - { - Main.wallLoaded[k] = true; - } - Resize2DArray(ref Main.wallAltTexture, nextWall); - Resize2DArray(ref Main.wallAltTextureInit, nextWall); - Resize2DArray(ref Main.wallAltTextureDrawn, nextWall); - Array.Resize(ref Main.wallTexture, nextWall); - Array.Resize(ref Main.wallHouse, nextWall); - Array.Resize(ref Main.wallDungeon, nextWall); - Array.Resize(ref Main.wallLight, nextWall); - Array.Resize(ref Main.wallBlend, nextWall); - Array.Resize(ref Main.wallLargeFrames, nextWall); - Array.Resize(ref Main.wallFrame, nextWall); - Array.Resize(ref Main.wallFrameCounter, nextWall); - Array.Resize(ref MapHelper.wallLookup, nextWall); - Array.Resize(ref WallID.Sets.Conversion.Grass, nextWall); - Array.Resize(ref WallID.Sets.Conversion.Stone, nextWall); - Array.Resize(ref WallID.Sets.Conversion.Sandstone, nextWall); - Array.Resize(ref WallID.Sets.Conversion.HardenedSand, nextWall); - Array.Resize(ref WallID.Sets.Transparent, nextWall); - Array.Resize(ref WallID.Sets.Corrupt, nextWall); - Array.Resize(ref WallID.Sets.Crimson, nextWall); - Array.Resize(ref WallID.Sets.Hallow, nextWall); - if(!unloading) - { - loaded = true; - } - } - - internal static void Unload() - { - loaded = false; - walls.Clear(); - nextWall = WallID.Count; - globalWalls.Clear(); - } - - //change type of Terraria.Tile.wall to ushort and fix associated compile errors - //in Terraria.IO.WorldFile.SaveWorldTiles increase length of array by 1 from 13 to 14 - //in Terraria.IO.WorldFile.SaveWorldTiles inside block if (tile.wall != 0) after incrementing num2 - // call WallLoader.WriteType(tile.wall, array, ref num2, ref b3); - internal static void WriteType(ushort wall, byte[] data, ref int index, ref byte flags) - { - if(wall > 255) - { - data[index] = (byte)(wall >> 8); - index++; - flags |= 32; - } - } - - //in Terraria.IO.WorldFile.LoadWorldTiles after setting tile.wall call - // WallLoader.ReadType(ref tile.wall, reader, b, modWalls); - //in Terraria.IO.WorldFile.ValidateWorld before if ((b2 & 16) == 16) - // replace fileIO.ReadByte(); with ushort wall = fileIO.ReadByte(); - // ushort _ = 0; WallLoader.ReadType(ref wall, fileIO, b2, new Dictionary()); - internal static void ReadType(ref ushort wall, BinaryReader reader, byte flags, IDictionary wallTable) - { - if((flags & 32) == 32) - { - wall |= (ushort)(reader.ReadByte() << 8); - } - if(wallTable.ContainsKey(wall)) - { - wall = (ushort)wallTable[wall]; - } - } - - //in Terraria.WorldGen.KillWall add if(!WallLoader.KillSound(i, j, tile.wall)) { } to beginning of - // if/else chain for playing sounds, and turn first if into else if - internal static bool KillSound(int i, int j, int type) - { - foreach(GlobalWall globalWall in globalWalls) - { - if(!globalWall.KillSound(i, j, type)) - { - return false; - } - } - ModWall modWall = GetWall(type); - if(modWall != null) - { - if(!modWall.KillSound(i, j)) - { - return false; - } - Main.PlaySound(modWall.soundType, i * 16, j * 16, modWall.soundStyle); - return false; - } - return true; - } - - //in Terraria.WorldGen.KillWall after if statement setting num to 3 add - // WallLoader.NumDust(i, j, tile.wall, fail, ref num); - internal static void NumDust(int i, int j, int type, bool fail, ref int numDust) - { - ModWall modWall = GetWall(type); - if(modWall != null) - { - modWall.NumDust(i, j, fail, ref numDust); - } - foreach(GlobalWall globalWall in globalWalls) - { - globalWall.NumDust(i, j, type, fail, ref numDust); - } - } - - //in Terraria.WorldGen.KillWall before if statements creating dust add - // if(!WallLoader.CreateDust(i, j, tile.wall, ref int num2)) { continue; } - internal static bool CreateDust(int i, int j, int type, ref int dustType) - { - foreach(GlobalWall globalWall in globalWalls) - { - if(!globalWall.CreateDust(i, j, type, ref dustType)) - { - return false; - } - } - ModWall modWall = GetWall(type); - if(modWall != null) - { - return modWall.CreateDust(i, j, ref dustType); - } - return true; - } - - //in Terraria.WorldGen.KillWall replace if (num4 > 0) with - // if (WallLoader.Drop(i, j, tile.wall, ref num4) && num4 > 0) - internal static bool Drop(int i, int j, int type, ref int dropType) - { - foreach(GlobalWall globalWall in globalWalls) - { - if(!globalWall.Drop(i, j, type, ref dropType)) - { - return false; - } - } - ModWall modWall = GetWall(type); - if(modWall != null) - { - return modWall.Drop(i, j, ref dropType); - } - return true; - } - - //in Terraria.WorldGen.KillWall after if statements setting fail to true call - // WallLoader.KillWall(i, j, tile.wall, ref fail); - internal static void KillWall(int i, int j, int type, ref bool fail) - { - ModWall modWall = GetWall(type); - if(modWall != null) - { - modWall.KillWall(i, j, ref fail); - } - foreach(GlobalWall globalWall in globalWalls) - { - globalWall.KillWall(i, j, type, ref fail); - } - } - - //in Terraria.Lighting.PreRenderPhase after wall modifies light call - // WallLoader.ModifyLight(n, num17, wall, ref num18, ref num19, ref num20); - internal static void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) - { - ModWall modWall = GetWall(type); - if(modWall != null) - { - modWall.ModifyLight(i, j, ref r, ref g, ref b); - } - foreach(GlobalWall globalWall in globalWalls) - { - globalWall.ModifyLight(i, j, type, ref r, ref g, ref b); - } - } - - //in Terraria.WorldGen.UpdateWorld after each call to TileLoader.RandomUpdate call - // WallLoader.RandomUpdate(num7, num8, Main.tile[num7, num8].wall); - // WallLoader.RandomUpdate(num64, num65, Main.tile[num64, num65].wall); - internal static void RandomUpdate(int i, int j, int type) - { - ModWall modWall = GetWall(type); - if(modWall != null) - { - modWall.RandomUpdate(i, j); - } - foreach(GlobalWall globalWall in globalWalls) - { - globalWall.RandomUpdate(i, j, type); - } - } - - //in Terraria.Main.Update after vanilla wall animations call WallLoader.AnimateWalls(); - internal static void AnimateWalls() - { - if(loaded) - { - foreach(ModWall modWall in walls.Values) - { - modWall.AnimateWall(ref Main.wallFrame[modWall.Type], ref Main.wallFrameCounter[modWall.Type]); - } - } - } - - //in Terraria.Main.DrawWalls before if statements that do the drawing add - // if(!WallLoader.PreDraw(j, i, wall, Main.spriteBatch)) - // { WallLoader.PostDraw(j, i, wall, Main.spriteBatch); continue; } - internal static bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - foreach(GlobalWall globalWall in globalWalls) - { - if(!globalWall.PreDraw(i, j, type, spriteBatch)) - { - return false; - } - } - ModWall modWall = GetWall(type); - if(modWall != null) - { - return modWall.PreDraw(i, j, spriteBatch); - } - return true; - } - - //in Terraria.Main.DrawWalls after wall outlines are drawn call - // WallLoader.PostDraw(j, i, wall, Main.spriteBatch); - internal static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - ModWall modWall = GetWall(type); - if(modWall != null) - { - modWall.PostDraw(i, j, spriteBatch); - } - foreach(GlobalWall globalWall in globalWalls) - { - globalWall.PostDraw(i, j, type, spriteBatch); - } - } -}} diff --git a/Patcher/patches/Terraria/Properties/AssemblyInfo.cs.patch b/patches/Terraria/Properties/AssemblyInfo.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Properties/AssemblyInfo.cs.patch rename to patches/Terraria/Properties/AssemblyInfo.cs.patch diff --git a/Patcher/patches/Terraria/Terraria.GameContent.Biomes/CaveHouseBiome.cs.patch b/patches/Terraria/Terraria.GameContent.Biomes/CaveHouseBiome.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria.GameContent.Biomes/CaveHouseBiome.cs.patch rename to patches/Terraria/Terraria.GameContent.Biomes/CaveHouseBiome.cs.patch diff --git a/Patcher/patches/Terraria/Terraria.GameContent.Biomes/DesertBiome.cs.patch b/patches/Terraria/Terraria.GameContent.Biomes/DesertBiome.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria.GameContent.Biomes/DesertBiome.cs.patch rename to patches/Terraria/Terraria.GameContent.Biomes/DesertBiome.cs.patch diff --git a/Patcher/patches/Terraria/Terraria.GameContent.Biomes/MiningExplosivesBiome.cs.patch b/patches/Terraria/Terraria.GameContent.Biomes/MiningExplosivesBiome.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria.GameContent.Biomes/MiningExplosivesBiome.cs.patch rename to patches/Terraria/Terraria.GameContent.Biomes/MiningExplosivesBiome.cs.patch diff --git a/Patcher/patches/Terraria/Terraria.ID/SetFactory.cs.patch b/patches/Terraria/Terraria.ID/SetFactory.cs.patch similarity index 53% rename from Patcher/patches/Terraria/Terraria.ID/SetFactory.cs.patch rename to patches/Terraria/Terraria.ID/SetFactory.cs.patch index c699667c47d..3af09f9687b 100644 --- a/Patcher/patches/Terraria/Terraria.ID/SetFactory.cs.patch +++ b/patches/Terraria/Terraria.ID/SetFactory.cs.patch @@ -1,32 +1,41 @@ --- src/merged\Terraria.ID\SetFactory.cs +++ src/Terraria\Terraria.ID\SetFactory.cs -@@ -52,18 +52,19 @@ +@@ -52,20 +52,21 @@ return result; } - public void Recycle(T[] buffer) -+ public void Recycle(bool[] buffer) - { - lock (this._queueLock) - { +- { +- lock (this._queueLock) +- { - if (typeof(T).Equals(typeof(bool))) - { - this._boolBufferCache.Enqueue((bool[])buffer); -+ this._boolBufferCache.Enqueue(buffer); - } +- } - else if (typeof(T).Equals(typeof(int))) - { - this._intBufferCache.Enqueue((int[])buffer); - } +- } +- } +- } ++ public void Recycle(bool[] buffer) ++ { ++ lock(this._queueLock) ++ { ++ this._boolBufferCache.Enqueue(buffer); ++ } ++ } + -+ public void Recycle(int[] buffer) -+ { -+ lock (this._queueLock) -+ { -+ this._intBufferCache.Enqueue(buffer); - } - } ++ public void Recycle(int[] buffer) ++ { ++ lock(this._queueLock) ++ { ++ this._intBufferCache.Enqueue(buffer); ++ } ++ } + public bool[] CreateBoolSet(params int[] types) + { @@ -117,7 +118,7 @@ } for (int j = 0; j < inputs.Length; j += 2) diff --git a/Patcher/patches/Terraria/Terraria.IO/WorldFile.cs.patch b/patches/Terraria/Terraria.IO/WorldFile.cs.patch similarity index 92% rename from Patcher/patches/Terraria/Terraria.IO/WorldFile.cs.patch rename to patches/Terraria/Terraria.IO/WorldFile.cs.patch index 3390694dc64..cdf84d16594 100644 --- a/Patcher/patches/Terraria/Terraria.IO/WorldFile.cs.patch +++ b/patches/Terraria/Terraria.IO/WorldFile.cs.patch @@ -1,6 +1,6 @@ --- src/merged\Terraria.IO\WorldFile.cs +++ src/Terraria\Terraria.IO\WorldFile.cs -@@ -1021,7 +1021,7 @@ +@@ -1020,7 +1020,7 @@ writer.Write(NPC.savedTaxCollector); writer.Write(Main.invasionSizeStart); writer.Write(WorldFile.tempCultistDelay); @@ -9,7 +9,7 @@ for (int j = 0; j < 540; j++) { writer.Write(NPC.killCount[j]); -@@ -1267,7 +1267,7 @@ +@@ -1266,7 +1266,7 @@ } } writer.Write(num); @@ -18,7 +18,7 @@ for (int i = 0; i < 1000; i++) { Chest chest = Main.chest[i]; -@@ -1281,7 +1281,7 @@ +@@ -1280,7 +1280,7 @@ Item item = chest.item[l]; if (item == null) { @@ -27,7 +27,7 @@ } else { -@@ -1840,7 +1840,7 @@ +@@ -1839,7 +1839,7 @@ } else { @@ -36,7 +36,7 @@ } } } -@@ -2432,7 +2432,7 @@ +@@ -2431,7 +2431,7 @@ } try { @@ -45,7 +45,7 @@ { using (BinaryReader binaryReader = new BinaryReader(stream)) { -@@ -2565,7 +2565,7 @@ +@@ -2564,7 +2564,7 @@ buffer = new byte[num]; SocialAPI.Cloud.Read(file, buffer, num); } diff --git a/Patcher/patches/Terraria/Terraria.Map/MapHelper.cs.patch b/patches/Terraria/Terraria.Map/MapHelper.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria.Map/MapHelper.cs.patch rename to patches/Terraria/Terraria.Map/MapHelper.cs.patch diff --git a/Patcher/patches/Terraria/Terraria.Map/MapTile.cs.patch b/patches/Terraria/Terraria.Map/MapTile.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria.Map/MapTile.cs.patch rename to patches/Terraria/Terraria.Map/MapTile.cs.patch diff --git a/Patcher/patches/Terraria/Terraria.UI/ItemSlot.cs.patch b/patches/Terraria/Terraria.UI/ItemSlot.cs.patch similarity index 90% rename from Patcher/patches/Terraria/Terraria.UI/ItemSlot.cs.patch rename to patches/Terraria/Terraria.UI/ItemSlot.cs.patch index 00c90402ec0..71d85a4e3fb 100644 --- a/Patcher/patches/Terraria/Terraria.UI/ItemSlot.cs.patch +++ b/patches/Terraria/Terraria.UI/ItemSlot.cs.patch @@ -5,7 +5,7 @@ case 3: case 4: - IL_A97: -+ default: ++ default: inv[slot].favorited = false; return; } diff --git a/patches/Terraria/Terraria.Utilities/PlatformUtilties.cs.patch b/patches/Terraria/Terraria.Utilities/PlatformUtilties.cs.patch new file mode 100644 index 00000000000..010a308557b --- /dev/null +++ b/patches/Terraria/Terraria.Utilities/PlatformUtilties.cs.patch @@ -0,0 +1,21 @@ +--- src/merged\Terraria.Utilities\PlatformUtilties.cs ++++ src/Terraria\Terraria.Utilities\PlatformUtilties.cs +@@ -10,7 +10,7 @@ + public static string GetClipboard() + { + string clipboardText = ""; +- Thread thread = new Thread(delegate ++ Thread thread = new Thread((ThreadStart)delegate + { + clipboardText = Clipboard.GetText(); + }); +@@ -31,7 +31,7 @@ + + public static void SetClipboard(string text) + { +- Thread thread = new Thread(delegate ++ Thread thread = new Thread((ThreadStart)delegate + { + if (text.Length > 0) + { + diff --git a/patches/Terraria/Terraria.csproj.patch b/patches/Terraria/Terraria.csproj.patch new file mode 100644 index 00000000000..58c09bb4c7d --- /dev/null +++ b/patches/Terraria/Terraria.csproj.patch @@ -0,0 +1,25 @@ +--- src/merged\Terraria.csproj ++++ src/Terraria\Terraria.csproj +@@ -27,11 +27,21 @@ + + + CLIENT ++ true + + + CLIENT + + ++ ++ Terraria\Libraries.DotNetZip.Ionic.Zip.CF.dll ++ ++ ++ Terraria\Libraries.JSON.NET.Newtonsoft.Json.dll ++ ++ ++ Terraria\Libraries.Steamworks.NET.Steamworks.NET.dll ++ + + + + diff --git a/Patcher/patches/Terraria/Terraria/Chest.cs.patch b/patches/Terraria/Terraria/Chest.cs.patch similarity index 96% rename from Patcher/patches/Terraria/Terraria/Chest.cs.patch rename to patches/Terraria/Terraria/Chest.cs.patch index 5ab0ed981dd..8934b7a7862 100644 --- a/Patcher/patches/Terraria/Terraria/Chest.cs.patch +++ b/patches/Terraria/Terraria/Chest.cs.patch @@ -4,8 +4,8 @@ } int num = (int)(Main.tile[X, Y].frameX / 36); int num2 = num; -+ short num3; -+ int type; ++ short num3; ++ int type; switch (num2) { case 2: diff --git a/Patcher/patches/Terraria/Terraria/Collision.cs.patch b/patches/Terraria/Terraria/Collision.cs.patch similarity index 83% rename from Patcher/patches/Terraria/Terraria/Collision.cs.patch rename to patches/Terraria/Terraria/Collision.cs.patch index 4152addf5bd..f167c252c08 100644 --- a/Patcher/patches/Terraria/Terraria/Collision.cs.patch +++ b/patches/Terraria/Terraria/Collision.cs.patch @@ -8,9 +8,10 @@ - { - goto IL_AA; - } +- num4 = Main.maxTilesY - 1; + if (num4 >= Main.maxTilesY) + { - num4 = Main.maxTilesY - 1; ++ num4 = Main.maxTilesY - 1; + } bool result; try @@ -29,9 +30,10 @@ - { - goto IL_AA; - } +- num4 = Main.maxTilesY - 1; + if (num4 >= Main.maxTilesY) + { - num4 = Main.maxTilesY - 1; ++ num4 = Main.maxTilesY - 1; + } bool result; try @@ -47,7 +49,7 @@ for (int i = 0; i < num16; i++) { - Main.tile[num, num2]; -+ //Main.tile[num, num2]; ++ Tile _ = Main.tile[num, num2]; if (Collision.HitWallSubstep(num, num2)) { goto Block_18; @@ -56,7 +58,7 @@ for (int j = 0; j < num17; j++) { - Main.tile[num, num2]; -+ //Main.tile[num, num2]; ++ Tile _ = Main.tile[num, num2]; if (Collision.HitWallSubstep(num, num2)) { goto Block_26; @@ -65,7 +67,7 @@ goto Block_33; } - Main.tile[num, num2]; -+ //Main.tile[num, num2]; ++ Tile _0 = Main.tile[num, num2]; if (Collision.HitWallSubstep(num, num2)) { goto Block_34; diff --git a/Patcher/patches/Terraria/Terraria/Dust.cs.patch b/patches/Terraria/Terraria/Dust.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria/Dust.cs.patch rename to patches/Terraria/Terraria/Dust.cs.patch diff --git a/patches/Terraria/Terraria/HitTile.cs.patch b/patches/Terraria/Terraria/HitTile.cs.patch new file mode 100644 index 00000000000..8b511cccb11 --- /dev/null +++ b/patches/Terraria/Terraria/HitTile.cs.patch @@ -0,0 +1,44 @@ +--- src/merged\Terraria\HitTile.cs ++++ src/Terraria\Terraria\HitTile.cs +@@ -136,7 +136,6 @@ + { + if (this.order[i] == tileId) + { +- IL_E1: + while (i > 1) + { + int num = this.order[i - 1]; +@@ -148,7 +147,14 @@ + goto IL_EE; + } + } +- goto IL_E1; ++ for (int k = 20; k > 1; k--) ++ { ++ int num = this.order[k - 1]; ++ this.order[k - 1] = this.order[k]; ++ this.order[k] = num; ++ } ++ this.order[1] = tileId; ++ goto IL_EE; + } + this.bufferLocation = this.order[20]; + this.data[this.bufferLocation].Clear(); +@@ -172,7 +178,6 @@ + { + if (this.order[i] == tileId) + { +- IL_47: + while (i < 20) + { + this.order[i] = this.order[i + 1]; +@@ -182,7 +187,7 @@ + return; + } + } +- goto IL_47; ++ this.order[20] = tileId; + } + + public void Prune() + diff --git a/Patcher/patches/Terraria/Terraria/Main.cs.patch b/patches/Terraria/Terraria/Main.cs.patch similarity index 82% rename from Patcher/patches/Terraria/Terraria/Main.cs.patch rename to patches/Terraria/Terraria/Main.cs.patch index 6e092028ed2..b0394b6b02c 100644 --- a/Patcher/patches/Terraria/Terraria/Main.cs.patch +++ b/patches/Terraria/Terraria/Main.cs.patch @@ -1,18 +1,6 @@ --- src/merged\Terraria\Main.cs +++ src/Terraria\Terraria\Main.cs -@@ -5189,7 +5189,11 @@ - Main.instance = this; - #if CLIENT - Main.graphics = new GraphicsDeviceManager((Game)this); -+#if DEBUG -+ base.Content.RootDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Content"); -+#else - base.Content.RootDirectory = "Content"; -+#endif - #endif - } - -@@ -11614,8 +11618,7 @@ +@@ -11626,8 +11626,7 @@ Main.butterflyCageMode[num17, num18] = (byte)Main.rand.Next(5); if (Main.rand.Next(2) == 0) { @@ -22,7 +10,7 @@ } } int num19 = Main.rand.Next(3, 16); -@@ -11657,13 +11660,11 @@ +@@ -11669,13 +11668,11 @@ { if (Main.butterflyCageMode[num17, num18] >= 10) { @@ -38,7 +26,7 @@ } } } -@@ -11687,13 +11688,11 @@ +@@ -11699,13 +11696,11 @@ { if (Main.butterflyCageMode[num17, num18] >= 10) { @@ -54,131 +42,100 @@ } } } -@@ -13920,16 +13919,14 @@ +@@ -13926,16 +13921,14 @@ public static string GetInputText(string oldString) { #if CLIENT -- Main.<>c__DisplayClassc <>c__DisplayClassc = new Main.<>c__DisplayClassc(); -- <>c__DisplayClassc.oldString = oldString; +- Main.<>c__DisplayClass6 <>c__DisplayClass = new Main.<>c__DisplayClass6(); +- <>c__DisplayClass.oldString = oldString; if (!Main.hasFocus) { -- return <>c__DisplayClassc.oldString; +- return <>c__DisplayClass.oldString; + return oldString; } Main.inputTextEnter = false; Main.inputTextEscape = false; -- string text = <>c__DisplayClassc.oldString; -- <>c__DisplayClassc.newKeys = ""; +- string text = <>c__DisplayClass.oldString; +- <>c__DisplayClass.newKeys = ""; + string text = oldString; + string newKeys = ""; if (text == null) { text = ""; -@@ -13943,11 +13940,11 @@ +@@ -13949,17 +13942,16 @@ } else if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X)) { -- Thread thread = new Thread(delegate -- { -- if (<>c__DisplayClassc.oldString.Length > 0) -- { -- Clipboard.SetText(<>c__DisplayClassc.oldString); -+ Thread thread = new Thread((ThreadStart)delegate -+ { -+ if (oldString.Length > 0) -+ { -+ Clipboard.SetText(oldString); - } - }); - thread.SetApartmentState(ApartmentState.STA); -@@ -13959,11 +13956,11 @@ +- PlatformUtilties.SetClipboard(<>c__DisplayClass.oldString); ++ PlatformUtilties.SetClipboard(oldString); + text = ""; } else if ((Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C)) || (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert))) { -- Thread thread2 = new Thread(delegate -- { -- if (<>c__DisplayClassc.oldString.Length > 0) -- { -- Clipboard.SetText(<>c__DisplayClassc.oldString); -+ Thread thread2 = new Thread((ThreadStart)delegate -+ { -+ if (oldString.Length > 0) -+ { -+ Clipboard.SetText(oldString); - } - }); - thread2.SetApartmentState(ApartmentState.STA); -@@ -13974,7 +13971,7 @@ +- PlatformUtilties.SetClipboard(<>c__DisplayClass.oldString); ++ PlatformUtilties.SetClipboard(oldString); } else if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V)) { -- Thread thread3 = new Thread(delegate -+ Thread thread3 = new Thread((ThreadStart)delegate - { - string text2 = Clipboard.GetText(); - for (int l = 0; l < text2.Length; l++) -@@ -13984,7 +13981,7 @@ - text2 = text2.Replace(string.Concat(text2[l--]), ""); - } - } -- <>c__DisplayClassc.newKeys += text2; -+ newKeys += text2; - }); - thread3.SetApartmentState(ApartmentState.STA); - thread3.Start(); -@@ -13999,11 +13996,11 @@ +- Main.<>c__DisplayClass6 expr_13B = <>c__DisplayClass; +- expr_13B.newKeys += PlatformUtilties.GetClipboard(); ++ newKeys += PlatformUtilties.GetClipboard(); + } + } + else +@@ -13968,11 +13960,11 @@ { if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete)) { -- Thread thread4 = new Thread(delegate +- Thread thread = new Thread(delegate - { -- if (<>c__DisplayClassc.oldString.Length > 0) +- if (<>c__DisplayClass.oldString.Length > 0) - { -- Clipboard.SetText(<>c__DisplayClassc.oldString); -+ Thread thread4 = new Thread((ThreadStart)delegate +- Clipboard.SetText(<>c__DisplayClass.oldString); ++ Thread thread = new Thread((ThreadStart)delegate + { + if (oldString.Length > 0) + { + Clipboard.SetText(oldString); } }); - thread4.SetApartmentState(ApartmentState.STA); -@@ -14015,7 +14012,7 @@ + thread.SetApartmentState(ApartmentState.STA); +@@ -13984,7 +13976,7 @@ } if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert)) { -- Thread thread5 = new Thread(delegate -+ Thread thread5 = new Thread((ThreadStart)delegate +- Thread thread2 = new Thread(delegate ++ Thread thread2 = new Thread((ThreadStart)delegate { string text2 = Clipboard.GetText(); for (int l = 0; l < text2.Length; l++) -@@ -14025,7 +14022,7 @@ +@@ -13994,7 +13986,7 @@ text2 = text2.Replace(string.Concat(text2[l--]), ""); } } -- <>c__DisplayClassc.newKeys += text2; +- <>c__DisplayClass.newKeys += text2; + newKeys += text2; }); - thread5.SetApartmentState(ApartmentState.STA); - thread5.Start(); -@@ -14048,13 +14045,12 @@ + thread2.SetApartmentState(ApartmentState.STA); + thread2.Start(); +@@ -14017,13 +14009,12 @@ } else if (num >= 32 && num != 127) { -- Main.<>c__DisplayClassc expr_2D1 = <>c__DisplayClassc; -- expr_2D1.newKeys += str; +- Main.<>c__DisplayClass6 expr_25B = <>c__DisplayClass; +- expr_25B.newKeys += str; + newKeys += str; } } } Main.keyCount = 0; -- text += <>c__DisplayClassc.newKeys; +- text += <>c__DisplayClass.newKeys; + text += newKeys; Main.oldInputText = Main.inputText; Main.inputText = Keyboard.GetState(); Microsoft.Xna.Framework.Input.Keys[] pressedKeys = Main.inputText.GetPressedKeys(); -@@ -18153,7 +18149,7 @@ - expr_6CCC_cp_0.velocity.Y = expr_6CCC_cp_0.velocity.Y - 2f; +@@ -18120,7 +18111,7 @@ + expr_6D05_cp_0.velocity.Y = expr_6D05_cp_0.velocity.Y - 2f; Main.dust[num147].noGravity = true; } - color.A = Main.mouseTextColor / 2; @@ -186,7 +143,7 @@ color.G = Main.mouseTextColor; color.B = Main.mouseTextColor; } -@@ -18165,8 +18161,8 @@ +@@ -18132,8 +18123,8 @@ int num148 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 43, 0f, 0f, 254, newColor, 0.5f); Main.dust[num148].velocity *= 0f; } @@ -197,10 +154,10 @@ if (b4 > color.G) { color.G = b4; -@@ -18430,9 +18426,9 @@ +@@ -18397,9 +18388,9 @@ } Microsoft.Xna.Framework.Color color11 = color; - Microsoft.Xna.Framework.Color color12 = array3[num152]; + Microsoft.Xna.Framework.Color color12 = array[num152]; - color11.R = (color.R + color12.R) / 2; - color11.G = (color.G + color12.G) / 2; - color11.B = (color.B + color12.B) / 2; @@ -210,10 +167,10 @@ if (flag16) { color11 = tile.actColor(color11); -@@ -18477,9 +18473,9 @@ +@@ -18444,9 +18435,9 @@ } Microsoft.Xna.Framework.Color color13 = color; - Microsoft.Xna.Framework.Color color14 = array3[num155]; + Microsoft.Xna.Framework.Color color14 = array[num155]; - color13.R = (color.R + color14.R) / 2; - color13.G = (color.G + color14.G) / 2; - color13.B = (color.B + color14.B) / 2; @@ -223,49 +180,33 @@ if (flag18) { color13 = tile.actColor(color13); -@@ -19342,7 +19338,7 @@ +@@ -19309,7 +19300,7 @@ } if (type5 == 334 && frameX2 >= 5000) { -- short arg_CB8A_0 = frameY3 / 18; -+ short arg_CB8A_0 = (short)(frameY3 / 18); +- short arg_CBC6_0 = frameY3 / 18; ++ short arg_CBC6_0 = (short)(frameY3 / 18); int num300 = (int)frameX2; int num301 = 0; int num302 = num300 % 5000; -@@ -20479,26 +20475,23 @@ - float num4; +@@ -20447,7 +20438,7 @@ switch (m) { -- case 0: + case 0: - IL_77B: -+ default: ++ default: num3 = num2; num4 = 0f; -- goto IL_7AF; -+ break; - case 1: - num3 = -num2; - num4 = 0f; -- goto IL_7AF; -+ break; - case 2: - num3 = 0f; - num4 = num2; -- goto IL_7AF; -+ break; - case 3: - num3 = 0f; + goto IL_7AF; +@@ -20464,7 +20455,6 @@ num4 = -num2; -- goto IL_7AF; -- } + goto IL_7AF; + } - goto IL_77B; -- IL_7AF: -+ break; -+ } + IL_7AF: position = new Vector2(player.position.X + num3, player.position.Y + player.gfxOffY + num4); this.DrawPlayer(player, position, player.fullRotation, player.fullRotationOrigin, player.ghostFade); - } -@@ -22149,7 +22142,7 @@ +@@ -22116,7 +22106,7 @@ if (type >= 87 && type <= 92) { Microsoft.Xna.Framework.Color alpha2 = Main.npc[i].GetAlpha(color9); @@ -274,39 +215,39 @@ if (alpha2.R < b4) { alpha2.R = b4; -@@ -25722,7 +25715,7 @@ +@@ -25689,7 +25679,7 @@ Microsoft.Xna.Framework.Color color29 = color25; color29 = projectile.GetAlpha(color29); color29 *= (float)(num171 - num173) / 15f; - projectile.oldPos[num173] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); -+ //projectile.oldPos[num173] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); ++ Vector2 _ = projectile.oldPos[num173] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); Main.spriteBatch.Draw(texture2D6, projectile.oldPos[num173] + new Vector2((float)projectile.width, (float)projectile.height) / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y4, texture2D6.Width, num170)), color29, projectile.rotation, new Vector2((float)texture2D6.Width / 2f, (float)num170 / 2f), MathHelper.Lerp(projectile.scale, value9, (float)num173 / 15f), spriteEffects, 0f); } Main.spriteBatch.Draw(texture2D6, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y4, texture2D6.Width, num170)), projectile.GetAlpha(color25), projectile.rotation, new Vector2((float)texture2D6.Width / 2f, (float)num170 / 2f), projectile.scale, spriteEffects, 0f); -@@ -25741,7 +25734,7 @@ +@@ -25708,7 +25698,7 @@ Microsoft.Xna.Framework.Color color30 = color25; color30 = projectile.GetAlpha(color30); color30 *= (float)(num175 - num177) / 15f; - projectile.oldPos[num177] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); -+ //projectile.oldPos[num177] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); ++ Vector2 _ = projectile.oldPos[num177] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); Main.spriteBatch.Draw(texture2D7, projectile.oldPos[num177] + new Vector2((float)projectile.width, (float)projectile.height) / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y5, texture2D7.Width, num174)), color30, projectile.rotation, new Vector2((float)texture2D7.Width / 2f, (float)num174 / 2f), MathHelper.Lerp(projectile.scale, value10, (float)num177 / 15f), spriteEffects, 0f); } Main.spriteBatch.Draw(texture2D7, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y5, texture2D7.Width, num174)), Microsoft.Xna.Framework.Color.White, projectile.rotation, new Vector2((float)texture2D7.Width / 2f, (float)num174 / 2f), projectile.scale + 0.2f, spriteEffects, 0f); -@@ -25957,7 +25950,7 @@ +@@ -25924,7 +25914,7 @@ Vector2 vector27 = new Vector2(projectile.scale); DelegateMethods.f_1 = 1f; DelegateMethods.c_1 = value16 * 0.75f * projectile.Opacity; - projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; -+ //projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; ++ Vector2 _ = projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; Utils.DrawLaser(Main.spriteBatch, tex, value17 - Main.screenPosition, value17 + projectile.velocity * num192 - Main.screenPosition, vector27, new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw)); DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 255, 255, 127) * 0.75f * projectile.Opacity; Utils.DrawLaser(Main.spriteBatch, tex, value17 - Main.screenPosition, value17 + projectile.velocity * num192 - Main.screenPosition, vector27 / 2f, new Utils.LaserLineFraming(DelegateMethods.RainbowLaserDraw)); -@@ -25977,14 +25970,14 @@ +@@ -25944,14 +25934,14 @@ DelegateMethods.f_1 = 1f; DelegateMethods.c_1 = c_; DelegateMethods.i_1 = 54000 - (int)Main.time / 2; - projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; -+ //projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; ++ Vector2 _ = projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; Utils.DrawLaser(Main.spriteBatch, tex2, value18 - Main.screenPosition, value18 + projectile.velocity * num193 - Main.screenPosition, vector28, new Utils.LaserLineFraming(DelegateMethods.TurretLaserDraw)); DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 255, 255, 127) * 0.75f * projectile.Opacity; Utils.DrawLaser(Main.spriteBatch, tex2, value18 - Main.screenPosition, value18 + projectile.velocity * num193 - Main.screenPosition, vector28 / 2f, new Utils.LaserLineFraming(DelegateMethods.TurretLaserDraw)); @@ -314,20 +255,20 @@ else if (projectile.type == 611) { - projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; -+ //projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; ++ Vector2 _ = projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; Texture2D texture2D17 = Main.projectileTexture[projectile.type]; Microsoft.Xna.Framework.Color alpha3 = projectile.GetAlpha(color25); if (projectile.velocity == Vector2.Zero) -@@ -26620,7 +26613,7 @@ +@@ -26587,7 +26577,7 @@ color47 = projectile.GetAlpha(color47); color47 *= (float)(num239 - num241) / 15f; Microsoft.Xna.Framework.Color alpha7 = projectile.GetAlpha(color25); - projectile.oldPos[num241] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); -+ //projectile.oldPos[num241] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); ++ Vector2 _ = projectile.oldPos[num241] - Main.screenPosition + new Vector2(num150 + (float)num149, (float)(projectile.height / 2) + projectile.gfxOffY); Main.spriteBatch.Draw(texture2D30, projectile.oldPos[num241] + new Vector2((float)projectile.width, (float)projectile.height) / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y12, texture2D30.Width, num238)), Microsoft.Xna.Framework.Color.Lerp(alpha7, color47, 0.3f), projectile.rotation, new Vector2((float)texture2D30.Width / 2f, (float)num238 / 2f), MathHelper.Lerp(projectile.scale, value37, (float)num241 / 15f), spriteEffects, 0f); } Main.spriteBatch.Draw(texture2D30, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y12, texture2D30.Width, num238)), projectile.GetAlpha(color25), projectile.rotation, new Vector2((float)texture2D30.Width / 2f, (float)num238 / 2f), projectile.scale, spriteEffects, 0f); -@@ -37855,7 +37848,7 @@ +@@ -37822,7 +37812,7 @@ Main.screenPosition.X = 0f; } Main.background = 0; @@ -336,7 +277,7 @@ Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color((int)b, (int)b, (int)b, 255); this.logoRotation += this.logoRotationSpeed * 3E-05f; if ((double)this.logoRotation > 0.1) -@@ -40456,9 +40449,9 @@ +@@ -40423,9 +40413,9 @@ if (num48 == 4) { color6 = color; @@ -349,7 +290,7 @@ } int num49 = 255; int num50 = (int)color6.R - (255 - num49); -@@ -40568,9 +40561,9 @@ +@@ -40535,9 +40525,9 @@ if (num59 == 4) { color7 = color; @@ -362,7 +303,7 @@ } int num60 = (int)color7.R - (255 - num57); if (num60 < 0) -@@ -40624,9 +40617,9 @@ +@@ -40591,9 +40581,9 @@ if (num67 == 4) { color8 = color; @@ -375,7 +316,7 @@ } int num68 = 255; int num69 = (int)color8.R - (255 - num68); -@@ -40714,9 +40707,9 @@ +@@ -40681,9 +40671,9 @@ break; } Microsoft.Xna.Framework.Color textColor = color; @@ -388,7 +329,7 @@ int num77 = 255; int num78 = (int)textColor.R - (255 - num77); if (num78 < 0) -@@ -40794,9 +40787,9 @@ +@@ -40761,9 +40751,9 @@ color9 = color; break; } @@ -401,7 +342,7 @@ } int num83 = (int)(255f * (this.menuItemScale[num35] * 2f - 1f)); if (array[num35]) -@@ -40837,7 +40830,7 @@ +@@ -40804,7 +40794,7 @@ } else { @@ -410,7 +351,7 @@ } } int num88 = 0; -@@ -40973,9 +40966,9 @@ +@@ -40940,9 +40930,9 @@ if (num93 == 4) { color10 = color; @@ -423,7 +364,7 @@ } color10.A = (byte)((float)color10.A * 0.3f); int num94 = 0; -@@ -41008,9 +41001,9 @@ +@@ -40975,9 +40965,9 @@ if (num96 == 4) { color11 = color; @@ -436,7 +377,7 @@ } color11.A = (byte)((float)color11.A * 0.3f); int num97 = 0; -@@ -41704,9 +41697,9 @@ +@@ -41671,9 +41661,9 @@ } break; } @@ -449,7 +390,7 @@ color4.R = (byte)((float)color4.R * x); color4.G = (byte)((float)color4.G * y); color4.B = (byte)((float)color4.B * z); -@@ -41754,9 +41747,9 @@ +@@ -41721,9 +41711,9 @@ num29 = 8; break; } @@ -462,7 +403,7 @@ color7.R = (byte)((float)color7.R * x); color7.G = (byte)((float)color7.G * y); color7.B = (byte)((float)color7.B * z); -@@ -42023,9 +42016,9 @@ +@@ -41990,9 +41980,9 @@ } break; } @@ -475,7 +416,7 @@ color15.R = (byte)((float)color15.R * x); color15.G = (byte)((float)color15.G * y); color15.B = (byte)((float)color15.B * z); -@@ -42063,9 +42056,9 @@ +@@ -42030,9 +42020,9 @@ num57 = 8; break; } @@ -488,7 +429,7 @@ color18.R = (byte)((float)color18.R * x); color18.G = (byte)((float)color18.G * y); color18.B = (byte)((float)color18.B * z); -@@ -42305,9 +42298,9 @@ +@@ -42272,9 +42262,9 @@ } break; } @@ -501,7 +442,7 @@ color26.R = (byte)((float)color26.R * x); color26.G = (byte)((float)color26.G * y); color26.B = (byte)((float)color26.B * z); -@@ -42336,9 +42329,9 @@ +@@ -42303,9 +42293,9 @@ num77 = 8; break; } @@ -514,7 +455,7 @@ color28.R = (byte)((float)color28.R * x); color28.G = (byte)((float)color28.G * y); color28.B = (byte)((float)color28.B * z); -@@ -42875,9 +42868,9 @@ +@@ -42842,9 +42832,9 @@ } break; } @@ -527,7 +468,7 @@ color4.R = (byte)((float)color4.R * num5); color4.G = (byte)((float)color4.G * num6); color4.B = (byte)((float)color4.B * num7); -@@ -42925,9 +42918,9 @@ +@@ -42892,9 +42882,9 @@ num35 = 8; break; } @@ -540,7 +481,7 @@ color7.R = (byte)((float)color7.R * num5); color7.G = (byte)((float)color7.G * num6); color7.B = (byte)((float)color7.B * num7); -@@ -43194,9 +43187,9 @@ +@@ -43161,9 +43151,9 @@ } break; } @@ -553,7 +494,7 @@ color15.R = (byte)((float)color15.R * num5); color15.G = (byte)((float)color15.G * num6); color15.B = (byte)((float)color15.B * num7); -@@ -43234,9 +43227,9 @@ +@@ -43201,9 +43191,9 @@ num63 = 8; break; } @@ -566,7 +507,7 @@ color18.R = (byte)((float)color18.R * num5); color18.G = (byte)((float)color18.G * num6); color18.B = (byte)((float)color18.B * num7); -@@ -43470,9 +43463,9 @@ +@@ -43437,9 +43427,9 @@ } break; } @@ -579,7 +520,7 @@ color26.R = (byte)((float)color26.R * num5); color26.G = (byte)((float)color26.G * num6); color26.B = (byte)((float)color26.B * num7); -@@ -43501,9 +43494,9 @@ +@@ -43468,9 +43458,9 @@ num83 = 8; break; } @@ -592,7 +533,7 @@ color28.R = (byte)((float)color28.R * num5); color28.G = (byte)((float)color28.G * num6); color28.B = (byte)((float)color28.B * num7); -@@ -45398,9 +45391,9 @@ +@@ -45365,9 +45355,9 @@ } } Main.tileColor.A = 255; @@ -605,7 +546,7 @@ Main.backColor = Main.bgColor; Main.trueBackColor = Main.backColor; Lighting.Initialize(true); -@@ -46891,10 +46884,10 @@ +@@ -46858,10 +46848,10 @@ num26 = (float)color4.B * num17; num27 = (float)color4.A * num17; color4 = new Microsoft.Xna.Framework.Color((int)((byte)num24), (int)((byte)num25), (int)((byte)num26), (int)((byte)num27)); @@ -620,7 +561,7 @@ Main.spriteBatch.Draw(Main.liquidTexture[num12], value - Main.screenPosition + new Vector2((float)num28, (float)num29) + zero, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(value2.X + num28, value2.Y + num29, width, height)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } -@@ -51113,9 +51106,9 @@ +@@ -51055,9 +51045,9 @@ } } Main.tileColor.A = 255; diff --git a/Patcher/patches/Terraria/Terraria/MessageBuffer.cs.patch b/patches/Terraria/Terraria/MessageBuffer.cs.patch similarity index 78% rename from Patcher/patches/Terraria/Terraria/MessageBuffer.cs.patch rename to patches/Terraria/Terraria/MessageBuffer.cs.patch index c3fa1024267..a0f1129601e 100644 --- a/Patcher/patches/Terraria/Terraria/MessageBuffer.cs.patch +++ b/patches/Terraria/Terraria/MessageBuffer.cs.patch @@ -5,7 +5,7 @@ { player5.pulley = true; - player5.pulleyDir = (bitsByte9[1] ? 2 : 1); -+ player5.pulleyDir = (byte)(bitsByte9[1] ? 2 : 1); ++ player5.pulleyDir = (bitsByte9[1] ? (byte)2 : (byte)1); } else { @@ -14,12 +14,12 @@ bitsByte11 = this.reader.ReadByte(); tile.active(bitsByte10[0]); - tile.wall = (bitsByte10[2] ? 1 : 0); -+ tile.wall = (byte)(bitsByte10[2] ? 1 : 0); ++ tile.wall = (bitsByte10[2] ? (byte)1 : (byte)0); bool flag8 = bitsByte10[3]; if (Main.netMode != 2) { - tile.liquid = (flag8 ? 1 : 0); -+ tile.liquid = (byte)(flag8 ? 1 : 0); ++ tile.liquid = (flag8 ? (byte)1 : (byte)0); } tile.wire(bitsByte10[4]); tile.halfBrick(bitsByte10[5]); diff --git a/Patcher/patches/Terraria/Terraria/NPC.cs.patch b/patches/Terraria/Terraria/NPC.cs.patch similarity index 59% rename from Patcher/patches/Terraria/Terraria/NPC.cs.patch rename to patches/Terraria/Terraria/NPC.cs.patch index 3b99f8249f5..ad8789dd6c4 100644 --- a/Patcher/patches/Terraria/Terraria/NPC.cs.patch +++ b/patches/Terraria/Terraria/NPC.cs.patch @@ -1,172 +1,132 @@ --- src/merged\Terraria\NPC.cs +++ src/Terraria\Terraria\NPC.cs -@@ -45372,19 +45372,15 @@ - case 2: - case 4: +@@ -45374,7 +45374,7 @@ case 5: -- goto IL_97D; -- case 3: + goto IL_97D; + case 3: - IL_95E: -+ break; + default: if (num8 != 0) { this.frame.Y = 0; - this.frameCounter = 0.0; -- goto IL_97D; -- } -- goto IL_97D; -- } +@@ -45383,7 +45383,6 @@ + } + goto IL_97D; + } - goto IL_95E; -- IL_97D: -+ } -+ break; -+ } + IL_97D: int num9; if (this.frameCounter < 10.0) - { -@@ -45516,19 +45512,15 @@ - case 2: - case 4: +@@ -45518,7 +45517,7 @@ case 5: -- goto IL_DC7; -- case 3: + goto IL_DC7; + case 3: - IL_DA8: -+ break; + default: if (num12 != 0) { this.frame.Y = 0; - this.frameCounter = 0.0; -- goto IL_DC7; -- } -- goto IL_DC7; -- } +@@ -45527,7 +45526,6 @@ + } + goto IL_DC7; + } - goto IL_DA8; -- IL_DC7: -+ } -+ break; -+ } + IL_DC7: int num13 = 0; if (this.frameCounter < 16.0) - { -@@ -45574,19 +45566,15 @@ - case 2: - case 4: +@@ -45576,7 +45574,7 @@ case 5: -- goto IL_F6F; -- case 3: + goto IL_F6F; + case 3: - IL_F50: -+ break; + default: if (num14 != 0) { this.frame.Y = 0; - this.frameCounter = 0.0; -- goto IL_F6F; -- } -- goto IL_F6F; -- } +@@ -45585,7 +45583,6 @@ + } + goto IL_F6F; + } - goto IL_F50; -- IL_F6F: -+ } -+ break; -+ } + IL_F6F: int num15; if (this.frameCounter < 10.0) - { -@@ -45755,19 +45743,15 @@ - case 2: - case 4: +@@ -45757,7 +45754,7 @@ case 5: -- goto IL_1396; -- case 3: + goto IL_1396; + case 3: - IL_1377: -+ break; + default: if (num28 != 0) { this.frame.Y = 0; - this.frameCounter = 0.0; -- goto IL_1396; -- } -- goto IL_1396; -- } +@@ -45766,7 +45763,6 @@ + } + goto IL_1396; + } - goto IL_1377; -- IL_1396: -+ } -+ break; -+ } + IL_1396: bool flag = this.ai[0] == 3f; int num29 = 0; - int num30 = 0; -@@ -45880,19 +45864,15 @@ - case 2: - case 4: +@@ -45882,7 +45878,7 @@ case 5: -- goto IL_16FF; -- case 3: + goto IL_16FF; + case 3: - IL_16E0: -+ break; + default: if (num33 != 0) { this.frame.Y = 0; - this.frameCounter = 0.0; -- goto IL_16FF; -- } -- goto IL_16FF; -- } +@@ -45891,7 +45887,6 @@ + } + goto IL_16FF; + } - goto IL_16E0; -- IL_16FF: -+ } -+ break; -+ } + IL_16FF: bool flag2 = this.ai[0] == 16f; int num34 = 0; - int num35 = -1; -@@ -56514,7 +56494,7 @@ +@@ -56514,7 +56509,7 @@ { if ((num54 == num51 - num53 || num54 == num51 + num53 || num55 == num52 - num53 || num55 == num52 + num53) && !Main.tile[num54, num55].active()) { - Main.tile[num54, num55].type = (WorldGen.crimson ? 347 : 140); -+ Main.tile[num54, num55].type = (ushort)(WorldGen.crimson ? 347 : 140); ++ Main.tile[num54, num55].type = (WorldGen.crimson ? (ushort)347 : (ushort)140); Main.tile[num54, num55].active(true); } Main.tile[num54, num55].lava(false); -@@ -63281,7 +63261,7 @@ +@@ -63281,7 +63276,7 @@ while ((double)num61 < 10.0 + dmg / 10.0) { int num62 = this.width / 4; - ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; -+ //((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; ++ Vector2 _ = ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; int num63 = Dust.NewDust(base.Center - Vector2.One * (float)num62, num62 * 2, num62 * 2, 229, 0f, 0f, 0, default(Color), 1f); Dust dust27 = Main.dust[num63]; Vector2 vector2 = Vector2.Normalize(dust27.position - base.Center); -@@ -63304,7 +63284,7 @@ +@@ -63304,7 +63299,7 @@ for (int num64 = 0; num64 < 60; num64++) { int num65 = this.width / 4; - ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; -+ //((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; ++ Vector2 _ = ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; int num66 = Dust.NewDust(base.Center - Vector2.One * (float)num65, num65 * 2, num65 * 2, 229, 0f, 0f, 0, default(Color), 1f); Dust dust28 = Main.dust[num66]; Vector2 vector3 = Vector2.Normalize(dust28.position - base.Center); -@@ -64182,7 +64162,7 @@ +@@ -64182,7 +64177,7 @@ for (int num163 = 0; num163 < 60; num163++) { int num164 = 25; - ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; -+ //((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; ++ Vector2 _ = ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; int num165 = Dust.NewDust(base.Center - Vector2.One * (float)num164, num164 * 2, num164 * 2, 212, 0f, 0f, 0, default(Color), 1f); Dust dust43 = Main.dust[num165]; Vector2 vector6 = Vector2.Normalize(dust43.position - base.Center); -@@ -71400,7 +71380,7 @@ +@@ -71400,7 +71395,7 @@ { if (this.boss) { - this.oldPosition - this.position; -+ //this.oldPosition - this.position; ++ Vector2 _ = this.oldPosition - this.position; if (this.netSpam <= 15) { this.netSpam += 5; diff --git a/Patcher/patches/Terraria/Terraria/NetMessage.cs.patch b/patches/Terraria/Terraria/NetMessage.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria/NetMessage.cs.patch rename to patches/Terraria/Terraria/NetMessage.cs.patch diff --git a/Patcher/patches/Terraria/Terraria/Player.cs.patch b/patches/Terraria/Terraria/Player.cs.patch similarity index 91% rename from Patcher/patches/Terraria/Terraria/Player.cs.patch rename to patches/Terraria/Terraria/Player.cs.patch index d99e234bc00..1038fa62a58 100644 --- a/Patcher/patches/Terraria/Terraria/Player.cs.patch +++ b/patches/Terraria/Terraria/Player.cs.patch @@ -5,7 +5,7 @@ list9.Add(tuple8); } - Main.tile[tuple8.Item1, tuple8.Item2]; -+ //Main.tile[tuple8.Item1, tuple8.Item2]; ++ Tile _ = Main.tile[tuple8.Item1, tuple8.Item2]; if (Collision.HitWallSubstep(tuple8.Item1, tuple8.Item2)) { list9.Add(tuple8); @@ -18,12 +18,11 @@ { using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateEncryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Write)) { -@@ -34938,7 +34938,7 @@ +@@ -34938,7 +34938,6 @@ { int[] array = new int[2]; this.hurtCooldowns = array; - base..ctor(); -+ //base..ctor(); this.width = 20; this.height = 42; this.name = string.Empty; diff --git a/Patcher/patches/Terraria/Terraria/Projectile.cs.patch b/patches/Terraria/Terraria/Projectile.cs.patch similarity index 53% rename from Patcher/patches/Terraria/Terraria/Projectile.cs.patch rename to patches/Terraria/Terraria/Projectile.cs.patch index d8c46e78116..4bfe8173dca 100644 --- a/Patcher/patches/Terraria/Terraria/Projectile.cs.patch +++ b/patches/Terraria/Terraria/Projectile.cs.patch @@ -1,12 +1,12 @@ --- src/merged\Terraria\Projectile.cs +++ src/Terraria\Terraria\Projectile.cs -@@ -11986,102 +11986,36 @@ +@@ -11986,100 +11986,34 @@ string name; if (Main.player[this.owner].active && (name = Main.player[this.owner].name) != null) { -- if ({58D555A4-F11B-4B40-A21C-EE99723CDD2C}.$$method0x600073b-1 == null) +- if ({925BC6E4-7F2B-447A-92FB-BAE94A6960E5}.$$method0x6000740-1 == null) - { -- {58D555A4-F11B-4B40-A21C-EE99723CDD2C}.$$method0x600073b-1 = new Dictionary(14) +- {925BC6E4-7F2B-447A-92FB-BAE94A6960E5}.$$method0x6000740-1 = new Dictionary(14) - { - { - "Tsuki", @@ -67,73 +67,91 @@ - }; - } - int num; -- if ({58D555A4-F11B-4B40-A21C-EE99723CDD2C}.$$method0x600073b-1.TryGetValue(name, out num)) +- if ({925BC6E4-7F2B-447A-92FB-BAE94A6960E5}.$$method0x6000740-1.TryGetValue(name, out num)) - { - switch (num) - { - case 0: - case 1: +- return 0.85f; +- case 2: +- return 0.33f; +- case 3: +- return 0.66f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.1f; +- case 4: +- return 0.77f; +- case 5: +- return 0.25f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.1f; +- case 6: +- return 0f; +- case 7: +- case 8: +- return 0.75f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.07f; +- case 9: +- return 0.075f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.07f; +- case 10: +- return 0.5f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.18f; +- case 11: +- return 0.75f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.05f; +- case 12: +- return 0.31f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.03f; +- case 13: +- return Main.rand.NextFloat(); +- } + switch (name) + { + case "Tsuki": + case "Yoraiz0r": - return 0.85f; -- case 2: ++ return 0.85f; + case "Ghostar": - return 0.33f; -- case 3: ++ return 0.33f; + case "Devalaous": - return 0.66f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.1f; -- case 4: ++ return 0.66f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.1f; + case "Leinfors": - return 0.77f; -- case 5: ++ return 0.77f; + case "Aeroblop": - return 0.25f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.1f; -- case 6: ++ return 0.25f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.1f; + case "Doylee": - return 0f; -- case 7: -- case 8: ++ return 0f; + case "Darkhalis": + case "Arkhalis": - return 0.75f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.07f; -- case 9: ++ return 0.75f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.07f; + case "Nike Leon": - return 0.075f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.07f; -- case 10: ++ return 0.075f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.07f; + case "Suweeka": - return 0.5f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.18f; -- case 11: ++ return 0.5f + (float)Math.Cos(Main.time / 180.0 * 6.2831854820251465) * 0.18f; + case "W1K": - return 0.75f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.05f; -- case 12: ++ return 0.75f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.05f; + case "Grox The Great": - return 0.31f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.03f; -- case 13: ++ return 0.31f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.03f; + case "Random": - return Main.rand.NextFloat(); - } ++ return Main.rand.NextFloat(); } -- } + } return (float)((int)indexing) / 6f; - } - @@ -20764,7 +20698,7 @@ int num688 = (int)(this.position.Y + (float)this.height) / 16 + 1; if (WorldGen.SolidTile(num687, num688) || Main.tile[num687, num688].halfBrick()) { - goto IL_1C179; -+ goto Block_1933;//IL_1C179; ++ goto Block_1933; } if (Main.tile[num687, num688].slope() > 0) { -@@ -34045,7 +33979,7 @@ +@@ -20776,7 +20710,6 @@ + Block_1933: + try + { +- IL_1C179: + num687 = (int)(this.position.X + (float)(this.width / 2)) / 16; + num688 = (int)(this.position.Y + (float)(this.height / 2)) / 16; + num687 += num681; +@@ -34045,7 +33978,7 @@ for (int n = 0; n < 5; n++) { int num29 = this.width / 4; - ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; -+ //((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; ++ Vector2 _ = ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * (float)Main.rand.Next(24, 41) / 8f; int num30 = Dust.NewDust(base.Center - Vector2.One * (float)num29, num29 * 2, num29 * 2, 88, 0f, 0f, 0, default(Color), 1f); Dust dust5 = Main.dust[num30]; Vector2 value3 = Vector2.Normalize(dust5.position - base.Center); diff --git a/Patcher/patches/Terraria/Terraria/Tile.cs.patch b/patches/Terraria/Terraria/Tile.cs.patch similarity index 100% rename from Patcher/patches/Terraria/Terraria/Tile.cs.patch rename to patches/Terraria/Terraria/Tile.cs.patch diff --git a/Patcher/patches/Terraria/Terraria/WaterfallManager.cs.patch b/patches/Terraria/Terraria/WaterfallManager.cs.patch similarity index 96% rename from Patcher/patches/Terraria/Terraria/WaterfallManager.cs.patch rename to patches/Terraria/Terraria/WaterfallManager.cs.patch index 546d6847997..90a243a8eb1 100644 --- a/Patcher/patches/Terraria/Terraria/WaterfallManager.cs.patch +++ b/patches/Terraria/Terraria/WaterfallManager.cs.patch @@ -4,7 +4,7 @@ int num18 = 0; int num19 = 0; int num20 = 0; -+ int num21; ++ int num21; int num22; if (num12 == 1 || num12 == 14) { diff --git a/Patcher/patches/Terraria/Terraria/WorldGen.cs.patch b/patches/Terraria/Terraria/WorldGen.cs.patch similarity index 91% rename from Patcher/patches/Terraria/Terraria/WorldGen.cs.patch rename to patches/Terraria/Terraria/WorldGen.cs.patch index b62cfa789fe..28436252c22 100644 --- a/Patcher/patches/Terraria/Terraria/WorldGen.cs.patch +++ b/patches/Terraria/Terraria/WorldGen.cs.patch @@ -9,27 +9,30 @@ int j2 = WorldGen.mCaveY[k]; WorldGen.CaveOpenater(i2, j2); WorldGen.Cavinator(i2, j2, WorldGen.genRand.Next(40, 50)); -@@ -8944,39 +8944,37 @@ +@@ -8940,6 +8940,8 @@ + int num2 = 400; + int num3 = 4; + int num4 = 275; ++ bool flag2; ++ int maxValue; + for (int k = 0; k < 3; k++) { int num5; - int num6; -+ int maxValue; -+ bool flag2; +@@ -8947,36 +8949,34 @@ switch (k) { -- case 0: + case 0: - { - IL_3D: -+ default: ++ default: + { num5 = 5; num6 = num4; - bool flag2 = false; - int maxValue = num3; -- goto IL_77; + flag2 = false; + maxValue = num3; -+ break; + goto IL_77; } case 1: { @@ -37,10 +40,9 @@ num6 = Main.maxTilesX - num2; - bool flag2 = true; - int maxValue = num; -- goto IL_77; + flag2 = true; + maxValue = num; -+ break; + goto IL_77; } case 2: { @@ -48,23 +50,20 @@ num6 = Main.maxTilesX - 5; - bool flag2 = false; - int maxValue = num3; -- goto IL_77; -- } -- } -- goto IL_3D; -- IL_77: + flag2 = false; + maxValue = num3; -+ break; -+ } -+ } + goto IL_77; + } + } +- goto IL_3D; + IL_77: for (int l = num5; l < num6; l++) { - int maxValue; if (WorldGen.genRand.Next(maxValue) == 0) { int num7 = 0; -@@ -8988,7 +8986,6 @@ +@@ -8988,7 +8988,6 @@ Tile tile2 = Main.tile[l, num7 - 1]; if (!tile2.active() && tile2.wall == 0) { @@ -72,7 +71,7 @@ if (flag2) { WorldGen.PlantCactus(l, num7); -@@ -10263,7 +10260,7 @@ +@@ -10263,7 +10262,7 @@ if (flag) { short num6 = (short)Math.Sign(num3); @@ -81,7 +80,7 @@ } } tile.active(true); -@@ -13167,7 +13164,7 @@ +@@ -13167,7 +13166,7 @@ Main.tile[x - 1, y - 1].frameY = 0; Main.tile[x, y - 1].active(true); Main.tile[x, y - 1].type = 31; @@ -90,7 +89,7 @@ Main.tile[x, y - 1].frameY = 0; Main.tile[x - 1, y].active(true); Main.tile[x - 1, y].type = 31; -@@ -13175,7 +13172,7 @@ +@@ -13175,7 +13174,7 @@ Main.tile[x - 1, y].frameY = 18; Main.tile[x, y].active(true); Main.tile[x, y].type = 31; @@ -99,52 +98,47 @@ Main.tile[x, y].frameY = 18; } -@@ -13649,33 +13646,30 @@ +@@ -13649,33 +13648,32 @@ int style16 = 32; int style17 = 32; int num37; -+ int num38; ++ int num38; switch (num36) { -- case 0: + case 0: - { - IL_F95: -+ default: ++ default: + { num37 = 1; - int num38 = 3; -- goto IL_FAB; + num38 = 3; -+ break; + goto IL_FAB; } case 1: { num37 = 3; - int num38 = 3; -- goto IL_FAB; + num38 = 3; -+ break; + goto IL_FAB; } case 2: { num37 = 1; - int num38 = 2; -- goto IL_FAB; -- } -- } -- goto IL_F95; -- IL_FAB: + num38 = 2; -+ break; -+ } -+ } + goto IL_FAB; + } + } +- goto IL_F95; + IL_FAB: for (int num39 = num34 - 1; num39 <= num34 + num37; num39++) { - int num38; for (int num40 = num35; num40 <= num35 + num38; num40++) { Tile tile = Main.tile[num34, num35]; -@@ -19802,7 +19796,7 @@ +@@ -19802,7 +19800,7 @@ Main.tile[num4 + 1, num2].active(true); Main.tile[num4 + 1, num2].type = 11; Main.tile[num4 + 1, num2].frameY = (short)num6; @@ -153,7 +147,7 @@ Main.tile[num4 + 1, num2].color(color); if (Main.tile[num4, num2 + 1] == null) { -@@ -19820,7 +19814,7 @@ +@@ -19820,7 +19818,7 @@ Main.tile[num4 + 1, num2 + 1].active(true); Main.tile[num4 + 1, num2 + 1].type = 11; Main.tile[num4 + 1, num2 + 1].frameY = (short)(num6 + 18); @@ -162,7 +156,7 @@ Main.tile[num4 + 1, num2 + 1].color(color2); if (Main.tile[num4, num2 + 2] == null) { -@@ -19838,7 +19832,7 @@ +@@ -19838,7 +19836,7 @@ Main.tile[num4 + 1, num2 + 2].active(true); Main.tile[num4 + 1, num2 + 2].type = 11; Main.tile[num4 + 1, num2 + 2].frameY = (short)(num6 + 36); @@ -171,7 +165,7 @@ Main.tile[num4 + 1, num2 + 2].color(color3); for (int m = num4 - 1; m <= num4 + 2; m++) { -@@ -21083,7 +21077,7 @@ +@@ -21083,7 +21081,7 @@ } else { @@ -180,7 +174,7 @@ } if ((style & 2) == 2) { -@@ -21092,7 +21086,7 @@ +@@ -21092,7 +21090,7 @@ } else { @@ -189,7 +183,7 @@ } if ((style & 4) == 4) { -@@ -21101,7 +21095,7 @@ +@@ -21101,7 +21099,7 @@ } else { @@ -198,7 +192,7 @@ } } if (obj == 1) -@@ -21113,7 +21107,7 @@ +@@ -21113,7 +21111,7 @@ } else { @@ -207,7 +201,7 @@ } if ((style & 2) == 2) { -@@ -21122,7 +21116,7 @@ +@@ -21122,7 +21120,7 @@ } else { @@ -216,7 +210,7 @@ } if ((style & 4) == 4) { -@@ -21131,7 +21125,7 @@ +@@ -21131,7 +21129,7 @@ } else { @@ -225,7 +219,7 @@ } } if (obj == 2) -@@ -21143,7 +21137,7 @@ +@@ -21143,7 +21141,7 @@ } else { @@ -234,7 +228,7 @@ } if ((style & 2) == 2) { -@@ -21152,7 +21146,7 @@ +@@ -21152,7 +21150,7 @@ } else { @@ -243,7 +237,7 @@ } if ((style & 4) == 4) { -@@ -21161,7 +21155,7 @@ +@@ -21161,7 +21159,7 @@ } else { @@ -252,7 +246,7 @@ } if ((style & 8) == 8) { -@@ -21170,7 +21164,7 @@ +@@ -21170,7 +21168,7 @@ } else { @@ -261,7 +255,7 @@ } } if (obj == 3) -@@ -21182,7 +21176,7 @@ +@@ -21182,7 +21180,7 @@ } else { @@ -270,7 +264,7 @@ } if ((style & 2) == 2) { -@@ -21191,7 +21185,7 @@ +@@ -21191,7 +21189,7 @@ } else { @@ -279,7 +273,7 @@ } if ((style & 4) == 4) { -@@ -21200,7 +21194,7 @@ +@@ -21200,7 +21198,7 @@ } else { @@ -288,7 +282,7 @@ } if ((style & 8) == 8) { -@@ -21208,7 +21202,7 @@ +@@ -21208,7 +21206,7 @@ expr_443.frameY |= 8192; return; } @@ -297,7 +291,7 @@ } } -@@ -22112,7 +22106,7 @@ +@@ -22112,7 +22110,7 @@ return white; } @@ -306,7 +300,7 @@ { int color2 = (int)(color ?? oldColor); Color newColor = WorldGen.paintColor(color2); -@@ -23791,7 +23785,7 @@ +@@ -23791,7 +23789,7 @@ Main.tile[x, y - 1].frameX = frameX; Main.tile[x, y - 1].type = type; Main.tile[x, y].active(true); @@ -315,7 +309,7 @@ Main.tile[x, y].frameX = frameX; Main.tile[x, y].type = type; } -@@ -23816,7 +23810,7 @@ +@@ -23816,7 +23814,7 @@ Main.tile[x, y].frameX = frameX; Main.tile[x, y].type = type; Main.tile[x, y + 1].active(true); @@ -324,7 +318,7 @@ Main.tile[x, y + 1].frameX = frameX; Main.tile[x, y + 1].type = type; } -@@ -24046,7 +24040,7 @@ +@@ -24046,7 +24044,7 @@ Main.tile[i, j].type = type; Main.tile[i + 1, j].active(true); Main.tile[i + 1, j].frameY = frameY; @@ -333,7 +327,7 @@ Main.tile[i + 1, j].type = type; return true; } -@@ -24738,15 +24732,15 @@ +@@ -24738,15 +24736,15 @@ Main.tile[X2 - 1, num - 1].type = type; Main.tile[X2, num - 1].active(true); Main.tile[X2, num - 1].frameY = num2; @@ -353,7 +347,7 @@ Main.tile[X2, num].type = type; return; } -@@ -24789,11 +24783,11 @@ +@@ -24789,11 +24787,11 @@ Main.tile[X2 - 1, Y2 - 1].type = type; Main.tile[X2, Y2 - 1].active(true); Main.tile[X2, Y2 - 1].frameY = 0; @@ -367,7 +361,7 @@ Main.tile[X2 + 1, Y2 - 1].type = type; Main.tile[X2 - 1, Y2].active(true); Main.tile[X2 - 1, Y2].frameY = 18; -@@ -24801,11 +24795,11 @@ +@@ -24801,11 +24799,11 @@ Main.tile[X2 - 1, Y2].type = type; Main.tile[X2, Y2].active(true); Main.tile[X2, Y2].frameY = 18; @@ -381,7 +375,7 @@ Main.tile[X2 + 1, Y2].type = type; } } -@@ -26749,15 +26743,15 @@ +@@ -26749,15 +26747,15 @@ Main.tile[x - 1, y - 1].type = type; Main.tile[x, y - 1].active(true); Main.tile[x, y - 1].frameY = (short)num2; @@ -400,7 +394,7 @@ Main.tile[x + 2, y - 1].type = type; Main.tile[x - 1, y].active(true); Main.tile[x - 1, y].frameY = (short)(num2 + 18); -@@ -26765,15 +26759,15 @@ +@@ -26765,15 +26763,15 @@ Main.tile[x - 1, y].type = type; Main.tile[x, y].active(true); Main.tile[x, y].frameY = (short)(num2 + 18); @@ -419,7 +413,7 @@ Main.tile[x + 2, y].type = type; } } -@@ -27670,8 +27664,8 @@ +@@ -27670,8 +27668,8 @@ public static bool ShiftTallGate(int x, int y, bool closing) { @@ -430,7 +424,7 @@ Tile tileSafely = Framing.GetTileSafely(x, y); if (tileSafely.type != num) { -@@ -27950,11 +27944,11 @@ +@@ -27950,11 +27948,11 @@ Main.tile[x - 1, y].type = type; Main.tile[x, y].active(true); Main.tile[x, y].frameY = 0; @@ -444,7 +438,7 @@ Main.tile[x + 1, y].type = type; } } -@@ -28032,11 +28026,11 @@ +@@ -28032,11 +28030,11 @@ Main.tile[x - 1, y].type = type; Main.tile[x, y].active(true); Main.tile[x, y].frameY = 0; @@ -458,7 +452,7 @@ Main.tile[x + 1, y].type = type; return; } -@@ -28046,11 +28040,11 @@ +@@ -28046,11 +28044,11 @@ Main.tile[x - 1, y - 1].type = type; Main.tile[x, y - 1].active(true); Main.tile[x, y - 1].frameY = 0; @@ -472,7 +466,7 @@ Main.tile[x + 1, y - 1].type = type; Main.tile[x - 1, y].active(true); Main.tile[x - 1, y].frameY = 18; -@@ -28058,11 +28052,11 @@ +@@ -28058,11 +28056,11 @@ Main.tile[x - 1, y].type = type; Main.tile[x, y].active(true); Main.tile[x, y].frameY = 18; @@ -486,7 +480,7 @@ Main.tile[x + 1, y].type = type; } } -@@ -28115,15 +28109,15 @@ +@@ -28115,15 +28113,15 @@ Main.tile[x - 1, y - 1].type = type; Main.tile[x, y - 1].active(true); Main.tile[x, y - 1].frameY = num; @@ -506,7 +500,7 @@ Main.tile[x, y].type = type; } } -@@ -31633,11 +31627,11 @@ +@@ -31633,11 +31631,11 @@ Main.tile[x - 1, y - 1].type = type; Main.tile[x, y - 1].active(true); Main.tile[x, y - 1].frameY = 0; @@ -520,7 +514,7 @@ Main.tile[x + 1, y - 1].type = type; Main.tile[x - 1, y].active(true); Main.tile[x - 1, y].frameY = 18; -@@ -31645,11 +31639,11 @@ +@@ -31645,11 +31643,11 @@ Main.tile[x - 1, y].type = type; Main.tile[x, y].active(true); Main.tile[x, y].frameY = 18; @@ -534,7 +528,7 @@ Main.tile[x + 1, y].type = type; } -@@ -45465,11 +45459,11 @@ +@@ -45465,11 +45463,11 @@ } else if ((num4 >= 0 && Main.tileSolid[num4] && !Main.tileNoAttach[num4]) || num4 == 124 || (num4 == 5 && num8 == 5 && num6 == 5)) { @@ -548,7 +542,7 @@ } else if (tile.wall > 0) { -@@ -45645,21 +45639,21 @@ +@@ -45645,21 +45643,21 @@ { if (tile.frameY < 108 || tile.frameY > 54) { @@ -573,7 +567,7 @@ } } else -@@ -45721,7 +45715,7 @@ +@@ -45721,7 +45719,7 @@ } if (tile.frameY < 54 || tile.frameY > 90) { @@ -582,7 +576,7 @@ } } else if (num28 >= 0 && Main.tileMoss[num28]) -@@ -45736,7 +45730,7 @@ +@@ -45736,7 +45734,7 @@ } if (tile.frameY < 108 || tile.frameY > 54) { @@ -591,7 +585,7 @@ } } else if (num29 >= 0 && Main.tileMoss[num29]) -@@ -45751,7 +45745,7 @@ +@@ -45751,7 +45749,7 @@ } if (tile.frameY < 162 || tile.frameY > 198) { diff --git a/patches/Terraria/TerrariaServer.csproj.patch b/patches/Terraria/TerrariaServer.csproj.patch new file mode 100644 index 00000000000..1572b1c797b --- /dev/null +++ b/patches/Terraria/TerrariaServer.csproj.patch @@ -0,0 +1,25 @@ +--- src/merged\TerrariaServer.csproj ++++ src/Terraria\TerrariaServer.csproj +@@ -27,11 +27,21 @@ + + + SERVER ++ true + + + SERVER + + ++ ++ Terraria\Libraries.DotNetZip.Ionic.Zip.CF.dll ++ ++ ++ Terraria\Libraries.JSON.NET.Newtonsoft.Json.dll ++ ++ ++ Terraria\Libraries.Steamworks.NET.Steamworks.NET.dll ++ + + + + diff --git a/Patcher/patches/merged/Terraria.GameContent.UI.Elements/UIHeader.cs.patch b/patches/merged/Terraria.GameContent.UI.Elements/UIHeader.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.GameContent.UI.Elements/UIHeader.cs.patch rename to patches/merged/Terraria.GameContent.UI.Elements/UIHeader.cs.patch diff --git a/Patcher/patches/merged/Terraria.Graphics.Capture/CaptureCamera.cs.patch b/patches/merged/Terraria.Graphics.Capture/CaptureCamera.cs.patch similarity index 90% rename from Patcher/patches/merged/Terraria.Graphics.Capture/CaptureCamera.cs.patch rename to patches/merged/Terraria.Graphics.Capture/CaptureCamera.cs.patch index 730bed4ef89..2faed3ff456 100644 --- a/Patcher/patches/merged/Terraria.Graphics.Capture/CaptureCamera.cs.patch +++ b/patches/merged/Terraria.Graphics.Capture/CaptureCamera.cs.patch @@ -1,6 +1,6 @@ --- src/decompiled\Terraria.Graphics.Capture\CaptureCamera.cs +++ src/merged\Terraria.Graphics.Capture\CaptureCamera.cs -@@ -340,6 +340,7 @@ +@@ -334,6 +334,7 @@ public void Dispose() { @@ -8,7 +8,7 @@ Monitor.Enter(this._captureLock); if (this._isDisposed) { -@@ -354,6 +355,7 @@ +@@ -348,6 +349,7 @@ CaptureCamera.CameraExists = false; this._isDisposed = true; Monitor.Exit(this._captureLock); diff --git a/Patcher/patches/merged/Terraria.Graphics.Capture/CaptureManager.cs.patch b/patches/merged/Terraria.Graphics.Capture/CaptureManager.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.Graphics.Capture/CaptureManager.cs.patch rename to patches/merged/Terraria.Graphics.Capture/CaptureManager.cs.patch diff --git a/Patcher/patches/merged/Terraria.Graphics/TextureManager.cs.patch b/patches/merged/Terraria.Graphics/TextureManager.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.Graphics/TextureManager.cs.patch rename to patches/merged/Terraria.Graphics/TextureManager.cs.patch diff --git a/Patcher/patches/merged/Terraria.Initializers/LaunchInitializer.cs.patch b/patches/merged/Terraria.Initializers/LaunchInitializer.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.Initializers/LaunchInitializer.cs.patch rename to patches/merged/Terraria.Initializers/LaunchInitializer.cs.patch diff --git a/Patcher/patches/merged/Terraria.Social.Steam/CoreSocialModule.cs.patch b/patches/merged/Terraria.Social.Steam/CoreSocialModule.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.Social.Steam/CoreSocialModule.cs.patch rename to patches/merged/Terraria.Social.Steam/CoreSocialModule.cs.patch diff --git a/Patcher/patches/merged/Terraria.Social/SocialAPI.cs.patch b/patches/merged/Terraria.Social/SocialAPI.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.Social/SocialAPI.cs.patch rename to patches/merged/Terraria.Social/SocialAPI.cs.patch diff --git a/Patcher/patches/merged/Terraria.Utilities/CrashDump.cs.patch b/patches/merged/Terraria.Utilities/CrashDump.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria.Utilities/CrashDump.cs.patch rename to patches/merged/Terraria.Utilities/CrashDump.cs.patch diff --git a/Patcher/patches/merged/Terraria.csproj.patch b/patches/merged/Terraria.csproj.patch similarity index 100% rename from Patcher/patches/merged/Terraria.csproj.patch rename to patches/merged/Terraria.csproj.patch diff --git a/Patcher/patches/merged/Terraria/Lang.cs.patch b/patches/merged/Terraria/Lang.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/Lang.cs.patch rename to patches/merged/Terraria/Lang.cs.patch diff --git a/Patcher/patches/merged/Terraria/Main.cs.patch b/patches/merged/Terraria/Main.cs.patch similarity index 86% rename from Patcher/patches/merged/Terraria/Main.cs.patch rename to patches/merged/Terraria/Main.cs.patch index a7867becdd3..3c23d4ade82 100644 --- a/Patcher/patches/merged/Terraria/Main.cs.patch +++ b/patches/merged/Terraria/Main.cs.patch @@ -18,7 +18,7 @@ { public delegate void OnPlayerSelected(PlayerFileData player); -@@ -3695,11 +3702,13 @@ +@@ -3704,11 +3711,13 @@ Main.mouseColor.R = Main.Configuration.Get("MouseColorR", Main.mouseColor.R); Main.mouseColor.G = Main.Configuration.Get("MouseColorG", Main.mouseColor.G); Main.mouseColor.B = Main.Configuration.Get("MouseColorB", Main.mouseColor.B); @@ -32,7 +32,7 @@ Main.SetDisplayMode(preferredBackBufferWidth, preferredBackBufferHeight, fullscreen); int num = 0; Main.Configuration.Get("LastLaunchedVersion", ref num); -@@ -3771,8 +3780,10 @@ +@@ -3780,8 +3789,10 @@ } if (num >= 91 && binaryReader.ReadBoolean()) { @@ -43,7 +43,7 @@ } if (num >= 4) { -@@ -5176,13 +5187,17 @@ +@@ -5185,17 +5196,21 @@ public Main() { Main.instance = this; @@ -56,12 +56,16 @@ protected void SetTitle() { +#if CLIENT - base.Window.Title = Lang.title(); + if (Main._cachedTitle == null) + { + Main._cachedTitle = Lang.title(); + } + base.Window.Title = Main._cachedTitle; +#endif } public static void InitLifeBytes() -@@ -5238,6 +5253,9 @@ +@@ -5251,6 +5266,9 @@ protected override void Initialize() { @@ -71,7 +75,7 @@ Main.LocalFavoriteData.Load(); Main.CloudFavoritesData.Load(); TileObjectData.Initialize(); -@@ -5248,9 +5266,14 @@ +@@ -5261,9 +5279,14 @@ ItemRarity.Initialize(); TileEntity.InitializeAll(); Main.InitializeItemAnimations(); @@ -86,7 +90,7 @@ WorldGen.RandomizeBackgrounds(); WorldGen.RandomizeCaveBackgrounds(); WorldGen.RandomizeMoonState(); -@@ -7584,17 +7607,20 @@ +@@ -7597,17 +7620,20 @@ Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); } @@ -107,7 +111,7 @@ keyBoardInput.newKeyEvent += delegate(char keyStroke) { if (Main.keyCount < 10) -@@ -7604,6 +7630,7 @@ +@@ -7617,6 +7643,7 @@ Main.keyCount++; } }; @@ -115,7 +119,7 @@ base.Initialize(); base.Window.AllowUserResizing = true; this.OpenSettings(); -@@ -7630,12 +7657,14 @@ +@@ -7642,12 +7669,14 @@ this.OpenRecent(); Star.SpawnStars(); WorldGen.RandomizeWeather(); @@ -130,7 +134,7 @@ foreach (DisplayMode current in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { if (current.Width >= Main.minScreenW && current.Height >= Main.minScreenH && current.Width <= Main.maxScreenW && current.Height <= Main.maxScreenH) -@@ -11787,10 +11816,12 @@ +@@ -11799,10 +11828,12 @@ protected override void Update(GameTime gameTime) { @@ -140,18 +144,18 @@ Main.OnTick(); } +#endif - if (Main._largeMethodFix) + if (Main._hasPendingNetmodeChange) { - Main._largeMethodFix = false; -@@ -13888,6 +13919,7 @@ + Main.netMode = Main._targetNetMode; +@@ -13894,6 +13925,7 @@ public static string GetInputText(string oldString) { +#if CLIENT - Main.<>c__DisplayClassc <>c__DisplayClassc = new Main.<>c__DisplayClassc(); - <>c__DisplayClassc.oldString = oldString; + Main.<>c__DisplayClass6 <>c__DisplayClass = new Main.<>c__DisplayClass6(); + <>c__DisplayClass.oldString = oldString; if (!Main.hasFocus) -@@ -14065,6 +14097,9 @@ +@@ -14034,6 +14066,9 @@ } } return text; @@ -161,7 +165,7 @@ } public void MouseText(string cursorText, int rare = 0, byte diff = 0) -@@ -37612,7 +37647,9 @@ +@@ -37579,7 +37614,9 @@ protected void QuitGame() { Main.SaveSettings(); @@ -171,7 +175,7 @@ base.Exit(); } -@@ -50016,6 +50053,7 @@ +@@ -49958,6 +49995,7 @@ private static void CheckMonoliths() { @@ -179,7 +183,7 @@ bool flag = Main.player[Main.myPlayer].ZoneTowerVortex || Main.player[Main.myPlayer].ZoneTowerNebula || Main.player[Main.myPlayer].ZoneTowerStardust || Main.player[Main.myPlayer].ZoneTowerSolar; for (int i = 0; i < Main.MonolithFilterNames.Length; i++) { -@@ -50042,6 +50080,7 @@ +@@ -49984,6 +50022,7 @@ } } } @@ -187,7 +191,7 @@ } protected override void Draw(GameTime gameTime) -@@ -50090,7 +50129,9 @@ +@@ -50032,7 +50071,9 @@ { Main.maxQ = true; } @@ -197,7 +201,7 @@ Main.drawTime++; Main.screenLastPosition = Main.screenPosition; if (Main.stackSplit == 0) -@@ -53016,6 +53057,7 @@ +@@ -52962,6 +53003,7 @@ Main.UpdateSundial(); Main.time += (double)Main.dayRate; CultistRitual.UpdateTime(); @@ -205,7 +209,7 @@ if (NPC.MoonLordCountdown > 0) { float num5 = MathHelper.Clamp((float)Math.Sin((double)((float)NPC.MoonLordCountdown / 60f * 0.5f)) * 2f, 0f, 1f); -@@ -53030,6 +53072,7 @@ +@@ -52976,6 +53018,7 @@ { Filters.Scene.Deactivate("MoonLordShake", new object[0]); } diff --git a/Patcher/patches/merged/Terraria/Minecart.cs.patch b/patches/merged/Terraria/Minecart.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/Minecart.cs.patch rename to patches/merged/Terraria/Minecart.cs.patch diff --git a/Patcher/patches/merged/Terraria/Mount.cs.patch b/patches/merged/Terraria/Mount.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/Mount.cs.patch rename to patches/merged/Terraria/Mount.cs.patch diff --git a/Patcher/patches/merged/Terraria/NPC.cs.patch b/patches/merged/Terraria/NPC.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/NPC.cs.patch rename to patches/merged/Terraria/NPC.cs.patch diff --git a/Patcher/patches/merged/Terraria/NetMessage.cs.patch b/patches/merged/Terraria/NetMessage.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/NetMessage.cs.patch rename to patches/merged/Terraria/NetMessage.cs.patch diff --git a/Patcher/patches/merged/Terraria/Netplay.cs.patch b/patches/merged/Terraria/Netplay.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/Netplay.cs.patch rename to patches/merged/Terraria/Netplay.cs.patch diff --git a/Patcher/patches/merged/Terraria/Player.cs.patch b/patches/merged/Terraria/Player.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/Player.cs.patch rename to patches/merged/Terraria/Player.cs.patch diff --git a/Patcher/patches/merged/Terraria/Program.cs.patch b/patches/merged/Terraria/Program.cs.patch similarity index 68% rename from Patcher/patches/merged/Terraria/Program.cs.patch rename to patches/merged/Terraria/Program.cs.patch index a40da7bf7ae..3f07f2346b1 100644 --- a/Patcher/patches/merged/Terraria/Program.cs.patch +++ b/patches/merged/Terraria/Program.cs.patch @@ -1,41 +1,40 @@ --- src/decompiled\Terraria\Program.cs +++ src/merged\Terraria\Program.cs -@@ -1,15 +1,21 @@ - using System; - using System.Collections.Generic; - using System.IO; --using System.Windows.Forms; - using Terraria.Initializers; - using Terraria.Social; +@@ -4,7 +4,9 @@ + using System.Reflection; + using System.Runtime.CompilerServices; + using System.Threading; +#if CLIENT -+using System.Windows.Forms; + using System.Windows.Forms; +#endif + using Terraria.Initializers; + using Terraria.Social; - namespace Terraria +@@ -12,7 +14,11 @@ { public static class Program { +#if CLIENT public const bool IsServer = false; +#else -+ public const bool IsServer = true; ++ public const bool IsServer = true; +#endif public static Dictionary LaunchParameters = new Dictionary(); -@@ -22,7 +28,11 @@ - { - SocialAPI.Initialize(null); - LaunchInitializer.LoadParameters(main); +@@ -94,7 +100,11 @@ + { + Program.ForceLoadAssembly(Assembly.GetExecutingAssembly(), true); + }; +#if CLIENT main.Run(); +#else -+ main.DedServ(); ++ main.DedServ(); +#endif } catch (Exception e) { -@@ -41,7 +51,14 @@ +@@ -113,7 +123,14 @@ streamWriter.WriteLine(e); streamWriter.WriteLine(""); } diff --git a/Patcher/patches/merged/Terraria/WindowsLaunch.cs.patch b/patches/merged/Terraria/WindowsLaunch.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/WindowsLaunch.cs.patch rename to patches/merged/Terraria/WindowsLaunch.cs.patch diff --git a/Patcher/patches/merged/Terraria/WorldGen.cs.patch b/patches/merged/Terraria/WorldGen.cs.patch similarity index 100% rename from Patcher/patches/merged/Terraria/WorldGen.cs.patch rename to patches/merged/Terraria/WorldGen.cs.patch diff --git a/Patcher/patches/merged/TerrariaServer.csproj.patch b/patches/merged/TerrariaServer.csproj.patch similarity index 100% rename from Patcher/patches/merged/TerrariaServer.csproj.patch rename to patches/merged/TerrariaServer.csproj.patch diff --git a/Patcher/patches/tModLoader/Terraria.GameContent.Generation/TrackGenerator.cs.patch b/patches/tModLoader/Terraria.GameContent.Generation/TrackGenerator.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria.GameContent.Generation/TrackGenerator.cs.patch rename to patches/tModLoader/Terraria.GameContent.Generation/TrackGenerator.cs.patch diff --git a/patches/tModLoader/Terraria.IO/PlayerFileData.cs.patch b/patches/tModLoader/Terraria.IO/PlayerFileData.cs.patch new file mode 100644 index 00000000000..a1ce09daed6 --- /dev/null +++ b/patches/tModLoader/Terraria.IO/PlayerFileData.cs.patch @@ -0,0 +1,27 @@ +--- src/Terraria\Terraria.IO\PlayerFileData.cs ++++ src/tModLoader\Terraria.IO\PlayerFileData.cs +@@ -3,6 +3,7 @@ + using System.Diagnostics; + using System.IO; + using System.Text.RegularExpressions; ++using Terraria.ModLoader.IO; + using Terraria.Social; + using Terraria.Utilities; + +@@ -96,6 +97,7 @@ + this._isCloudSave = true; + this._path = playerPathFromName; + Main.CloudFavoritesData.SaveFavorite(this); ++ PlayerIO.MoveToCloud(base.Path, playerPathFromName); + } + } + +@@ -128,6 +130,7 @@ + this._isCloudSave = false; + this._path = playerPathFromName; + Main.LocalFavoriteData.SaveFavorite(this); ++ PlayerIO.MoveToLocal(base.Path, playerPathFromName); + } + } + + diff --git a/patches/tModLoader/Terraria.IO/WorldFile.cs.patch b/patches/tModLoader/Terraria.IO/WorldFile.cs.patch new file mode 100644 index 00000000000..37e75eb0769 --- /dev/null +++ b/patches/tModLoader/Terraria.IO/WorldFile.cs.patch @@ -0,0 +1,59 @@ +--- src/Terraria\Terraria.IO\WorldFile.cs ++++ src/tModLoader\Terraria.IO\WorldFile.cs +@@ -5,6 +5,8 @@ + using Terraria.DataStructures; + using Terraria.GameContent.Events; + using Terraria.ID; ++using Terraria.ModLoader; ++using Terraria.ModLoader.IO; + using Terraria.Social; + using Terraria.Utilities; + +@@ -106,6 +108,7 @@ + } + binaryReader.Close(); + memoryStream.Close(); ++ WorldIO.ReadModFile(Main.worldPathName, flag); + if (num2 != 0) + { + WorldGen.loadFailed = true; +@@ -302,6 +305,7 @@ + { + FileUtilities.WriteAllBytes(text, array2, useCloudSaving); + } ++ WorldIO.WriteModFile(Main.worldPathName, useCloudSaving); + WorldGen.saveLock = false; + } + Main.serverGenLock = false; +@@ -1050,7 +1054,7 @@ + byte b2; + byte b = b2 = (b3 = 0); + bool flag = false; +- if (tile.active()) ++ if (tile.active() && tile.type < TileID.Count) + { + flag = true; + if (tile.type == 127) +@@ -1103,10 +1107,10 @@ + num2++; + } + } +- if (tile.wall != 0) ++ if (tile.wall != 0 && tile.wall < WallID.Count) + { + b2 |= 4; +- array[num2] = tile.wall; ++ array[num2] = (byte)tile.wall; + num2++; + if (tile.wallColor() != 0) + { +@@ -1260,7 +1264,7 @@ + for (int l = 0; l < 40; l++) + { + Item item = chest.item[l]; +- if (item == null) ++ if (item == null || ItemLoader.IsModItem(item)) + { + writer.Write((short)0); + } + diff --git a/patches/tModLoader/Terraria.IO/WorldFileData.cs.patch b/patches/tModLoader/Terraria.IO/WorldFileData.cs.patch new file mode 100644 index 00000000000..b8040817947 --- /dev/null +++ b/patches/tModLoader/Terraria.IO/WorldFileData.cs.patch @@ -0,0 +1,26 @@ +--- src/Terraria\Terraria.IO\WorldFileData.cs ++++ src/tModLoader\Terraria.IO\WorldFileData.cs +@@ -1,5 +1,6 @@ + using System; + using System.IO; ++using Terraria.ModLoader.IO; + using Terraria.Utilities; + + namespace Terraria.IO +@@ -106,6 +107,7 @@ + this._isCloudSave = true; + this._path = worldPathFromName; + Main.CloudFavoritesData.SaveFavorite(this); ++ WorldIO.MoveToCloud(base.Path, worldPathFromName); + } + } + +@@ -122,6 +124,7 @@ + this._isCloudSave = false; + this._path = worldPathFromName; + Main.LocalFavoriteData.SaveFavorite(this); ++ WorldIO.MoveToLocal(base.Path, worldPathFromName); + } + } + } + diff --git a/Patcher/patches/tModLoader/Terraria.Map/MapHelper.cs.patch b/patches/tModLoader/Terraria.Map/MapHelper.cs.patch similarity index 69% rename from Patcher/patches/tModLoader/Terraria.Map/MapHelper.cs.patch rename to patches/tModLoader/Terraria.Map/MapHelper.cs.patch index 60514bfe78a..cc2f44a9bbf 100644 --- a/Patcher/patches/tModLoader/Terraria.Map/MapHelper.cs.patch +++ b/patches/tModLoader/Terraria.Map/MapHelper.cs.patch @@ -29,13 +29,4 @@ } public static void SaveMap() -@@ -1843,7 +1849,7 @@ - { - using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) - { -- using (DeflateStream deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress)) -+ using (DeflateStream deflateStream = new DeflateStream(memoryStream, 0)) - { - int num = 0; - byte[] array = new byte[16384]; diff --git a/Patcher/patches/tModLoader/Terraria.Map/MapTile.cs.patch b/patches/tModLoader/Terraria.Map/MapTile.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria.Map/MapTile.cs.patch rename to patches/tModLoader/Terraria.Map/MapTile.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria.Map/WorldMap.cs.patch b/patches/tModLoader/Terraria.Map/WorldMap.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria.Map/WorldMap.cs.patch rename to patches/tModLoader/Terraria.Map/WorldMap.cs.patch diff --git a/patches/tModLoader/Terraria.ModLoader.IO/ItemIO.cs b/patches/tModLoader/Terraria.ModLoader.IO/ItemIO.cs new file mode 100644 index 00000000000..9adc63de47b --- /dev/null +++ b/patches/tModLoader/Terraria.ModLoader.IO/ItemIO.cs @@ -0,0 +1,96 @@ +using System; +using System.IO; +using Terraria; +using Terraria.ModLoader; + +namespace Terraria.ModLoader.IO +{ + internal static class ItemIO + { + //replace netID writes in Terraria.Player.SavePlayer + //in Terraria.IO.WorldFile.SaveChests include IsModItem for no-item check + internal static void WriteVanillaID(Item item, BinaryWriter writer) + { + writer.Write(ItemLoader.IsModItem(item) ? 0 : item.netID); + } + + internal static bool WriteModItemSlot(Item[] inv, int slot, BinaryWriter writer, bool writeStack = false, bool writeFavorite = false) + { + Item item = inv[slot]; + if (ItemLoader.IsModItem(item)) + { + writer.Write((ushort)slot); + WriteModItem(item, writer); + if (writeStack) + { + writer.Write(item.stack); + } + if (writeFavorite) + { + writer.Write(item.favorited); + } + return true; + } + return false; + } + + internal static void ReadModItemSlot(Item[] inv, BinaryReader reader, bool readStack = false, bool readFavorite = false) + { + int slot = reader.ReadUInt16(); + Item item = inv[slot]; + ReadModItem(item, reader); + if (readStack) + { + item.stack = reader.ReadInt32(); + } + if (readFavorite) + { + item.favorited = reader.ReadBoolean(); + } + } + + internal static void WriteModItem(Item item, BinaryWriter writer) + { + writer.Write(item.modItem.mod.Name); + writer.Write(Main.itemName[item.type]); + byte[] data; + using (MemoryStream memoryStream = new MemoryStream()) + { + using (BinaryWriter customWriter = new BinaryWriter(memoryStream)) + { + item.modItem.SaveCustomData(customWriter); + customWriter.Flush(); + data = memoryStream.ToArray(); + } + } + writer.Write((ushort)data.Length); + if (data.Length > 0) + { + writer.Write(data); + } + writer.Write(item.prefix); + } + + internal static void ReadModItem(Item item, BinaryReader reader) + { + string modName = reader.ReadString(); + string itemName = reader.ReadString(); + Mod mod = ModLoader.GetMod(modName); + int type = mod == null ? 0 : mod.ItemType(itemName); + item.netDefaults(type); + int dataLength = reader.ReadUInt16(); + if (dataLength > 0) + { + byte[] data = reader.ReadBytes(dataLength); + using (MemoryStream memoryStream = new MemoryStream(data)) + { + using (BinaryReader customReader = new BinaryReader(memoryStream)) + { + item.modItem.LoadCustomData(customReader); + } + } + } + item.Prefix(reader.ReadByte()); + } + } +} diff --git a/patches/tModLoader/Terraria.ModLoader.IO/PlayerIO.cs b/patches/tModLoader/Terraria.ModLoader.IO/PlayerIO.cs new file mode 100644 index 00000000000..b31d73de893 --- /dev/null +++ b/patches/tModLoader/Terraria.ModLoader.IO/PlayerIO.cs @@ -0,0 +1,230 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using Terraria; +using Terraria.Social; +using Terraria.Utilities; + +namespace Terraria.ModLoader.IO +{ + internal static class PlayerIO + { + private const byte numFlagBytes = 1; + //make Terraria.Player.ENCRYPTION_KEY internal + //add to end of Terraria.Player.SavePlayer + internal static void WriteModFile(Player player, string path, bool isCloudSave) + { + path = Path.ChangeExtension(path, ".tplr"); + if (FileUtilities.Exists(path, isCloudSave)) + { + FileUtilities.Copy(path, path + ".bak", isCloudSave, true); + } + byte[] flags; + byte[] data; + using (MemoryStream stream = new MemoryStream()) + { + using (BinaryWriter writer = new BinaryWriter(stream)) + { + flags = WriteModPlayer(player, writer); + writer.Flush(); + data = stream.ToArray(); + } + } + RijndaelManaged rijndaelManaged = new RijndaelManaged(); + using (Stream stream = isCloudSave ? (Stream)new MemoryStream() : (Stream)new FileStream(path, FileMode.Create)) + { + using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateEncryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Write)) + { + using (BinaryWriter writer = new BinaryWriter(cryptoStream)) + { + byte limit; + for (limit = (byte)flags.Length; limit > 0; limit--) + { + if (flags[limit - 1] != 0) + { + break; + } + } + writer.Write(limit); + if (limit > 0) + { + writer.Write(flags, 0, limit); + writer.Write(data); + } + writer.Flush(); + cryptoStream.FlushFinalBlock(); + stream.Flush(); + if (isCloudSave && SocialAPI.Cloud != null) + { + SocialAPI.Cloud.Write(path, ((MemoryStream)stream).ToArray()); + } + } + } + } + } + //add near end of Terraria.Player.LoadPlayer before accessory check + internal static void ReadModFile(Player player, string path, bool isCloudSave) + { + path = Path.ChangeExtension(path, ".tplr"); + RijndaelManaged rijndaelManaged = new RijndaelManaged(); + rijndaelManaged.Padding = PaddingMode.None; + if (!FileUtilities.Exists(path, isCloudSave)) + { + return; + } + byte[] buffer = FileUtilities.ReadAllBytes(path, isCloudSave); + using (MemoryStream stream = new MemoryStream(buffer)) + { + using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateDecryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Read)) + { + using (BinaryReader reader = new BinaryReader(cryptoStream)) + { + byte limit = reader.ReadByte(); + if (limit == 0) + { + return; + } + byte[] flags = reader.ReadBytes(limit); + if (flags.Length < numFlagBytes) + { + Array.Resize(ref flags, numFlagBytes); + } + ReadModPlayer(player, flags, reader); + } + } + } + } + + internal static byte[] WriteModPlayer(Player player, BinaryWriter writer) + { + byte[] flags = new byte[numFlagBytes]; + if (WriteInventory(player.armor, writer)) + { + flags[0] |= 1; + } + if (WriteInventory(player.dye, writer)) + { + flags[0] |= 2; + } + if (WriteInventory(player.inventory, writer, true, true)) + { + flags[0] |= 4; + } + if (WriteInventory(player.miscEquips, writer)) + { + flags[0] |= 8; + } + if (WriteInventory(player.miscDyes, writer)) + { + flags[0] |= 16; + } + if (WriteInventory(player.bank.item, writer, true)) + { + flags[0] |= 32; + } + if (WriteInventory(player.bank2.item, writer, true)) + { + flags[0] |= 64; + } + return flags; + } + + internal static void ReadModPlayer(Player player, byte[] flags, BinaryReader reader) + { + if ((flags[0] & 1) == 1) + { + ReadInventory(player.armor, reader); + } + if ((flags[0] & 2) == 2) + { + ReadInventory(player.dye, reader); + } + if ((flags[0] & 4) == 4) + { + ReadInventory(player.inventory, reader, true, true); + } + if ((flags[0] & 8) == 8) + { + ReadInventory(player.miscEquips, reader); + } + if ((flags[0] & 16) == 16) + { + ReadInventory(player.miscDyes, reader); + } + if ((flags[0] & 32) == 32) + { + ReadInventory(player.bank.item, reader, true); + } + if ((flags[0] & 64) == 64) + { + ReadInventory(player.bank2.item, reader, true); + } + } + + internal static bool WriteInventory(Item[] inv, BinaryWriter writer, bool writeStack = false, bool writeFavorite = false) + { + ushort count = 0; + byte[] data; + using (MemoryStream stream = new MemoryStream()) + { + using (BinaryWriter invWriter = new BinaryWriter(stream)) + { + for (int k = 0; k < inv.Length; k++) + { + if (ItemIO.WriteModItemSlot(inv, k, invWriter, writeStack, writeFavorite)) + { + count++; + } + } + invWriter.Flush(); + data = stream.ToArray(); + } + } + if (count > 0) + { + writer.Write(count); + writer.Write(data); + return true; + } + return false; + } + + internal static void ReadInventory(Item[] inv, BinaryReader reader, bool readStack = false, bool readFavorite = false) + { + int count = reader.ReadUInt16(); + for (int k = 0; k < count; k++) + { + ItemIO.ReadModItemSlot(inv, reader, readStack, readFavorite); + } + } + //add to end of Terraria.IO.PlayerFileData.MoveToCloud + internal static void MoveToCloud(string localPath, string cloudPath) + { + localPath = Path.ChangeExtension(localPath, ".tplr"); + cloudPath = Path.ChangeExtension(cloudPath, ".tplr"); + if (File.Exists(localPath)) + { + FileUtilities.MoveToCloud(localPath, cloudPath); + } + } + //add to end of Terraria.IO.PlayerFileData.MoveToLocal + internal static void MoveToLocal(string cloudPath, string localPath) + { + cloudPath = Path.ChangeExtension(cloudPath, ".tplr"); + localPath = Path.ChangeExtension(localPath, ".tplr"); + if (FileUtilities.Exists(cloudPath, true)) + { + FileUtilities.MoveToLocal(cloudPath, localPath); + } + } + //add to Terraria.Player.GetFileData after moving vanilla .bak file + internal static void LoadBackup(string path, bool cloudSave) + { + path = Path.ChangeExtension(path, ".tplr"); + if (FileUtilities.Exists(path + ".bak", cloudSave)) + { + FileUtilities.Move(path + ".bak", path, cloudSave, true); + } + } + } +} diff --git a/patches/tModLoader/Terraria.ModLoader.IO/TileIO.cs b/patches/tModLoader/Terraria.ModLoader.IO/TileIO.cs new file mode 100644 index 00000000000..c9247e84875 --- /dev/null +++ b/patches/tModLoader/Terraria.ModLoader.IO/TileIO.cs @@ -0,0 +1,352 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Terraria.ModLoader.IO +{ + internal static class TileIO + { + //in Terraria.IO.WorldFile.SaveWorldTiles add type check to tile.active() check and wall check + internal struct Tables + { + internal IDictionary tiles; + internal IDictionary frameImportant; + internal IDictionary walls; + + internal static Tables Create() + { + Tables tables = new Tables(); + tables.tiles = new Dictionary(); + tables.frameImportant = new Dictionary(); + tables.walls = new Dictionary(); + return tables; + } + } + + internal static bool WriteTiles(BinaryWriter writer) + { + IList types = new List(); + IList walls = new List(); + for (int i = 0; i < Main.maxTilesX; i++) + { + for (int j = 0; j < Main.maxTilesY; j++) + { + Tile tile = Main.tile[i, j]; + if (tile.active() && tile.type >= TileID.Count) + { + types.Add(tile.type); + } + if (tile.wall >= WallID.Count) + { + walls.Add(tile.wall); + } + } + } + if (types.Count > 0 || walls.Count > 0) + { + writer.Write((ushort)types.Count); + foreach (ushort type in types) + { + writer.Write(type); + ModTile modTile = TileLoader.GetTile(type); + writer.Write(modTile.mod.Name); + writer.Write(modTile.Name); + writer.Write(Main.tileFrameImportant[type]); + } + writer.Write((ushort)walls.Count); + foreach (ushort wall in walls) + { + writer.Write(wall); + ModWall modWall = WallLoader.GetWall(wall); + writer.Write(modWall.mod.Name); + writer.Write(modWall.Name); + } + WriteTileData(writer); + return true; + } + return false; + } + + internal static void ReadTiles(BinaryReader reader) + { + Tables tables = Tables.Create(); + ushort count = reader.ReadUInt16(); + for (int k = 0; k < count; k++) + { + ushort type = reader.ReadUInt16(); + string modName = reader.ReadString(); + string name = reader.ReadString(); + Mod mod = ModLoader.GetMod(modName); + tables.tiles[type] = mod == null ? (ushort)0 : (ushort)mod.TileType(name); + tables.frameImportant[type] = reader.ReadBoolean(); + } + count = reader.ReadUInt16(); + for (int k = 0; k < count; k++) + { + ushort wall = reader.ReadUInt16(); + string modName = reader.ReadString(); + string name = reader.ReadString(); + Mod mod = ModLoader.GetMod(modName); + tables.walls[wall] = mod == null ? (ushort)0 : (ushort)mod.WallType(name); + } + ReadTileData(reader, tables); + } + + internal static void WriteTileData(BinaryWriter writer) + { + byte skip = 0; + bool nextModTile = false; + int i = 0; + int j = 0; + do + { + Tile tile = Main.tile[i, j]; + if (HasModData(tile)) + { + if (!nextModTile) + { + writer.Write(skip); + skip = 0; + } + else + { + nextModTile = false; + } + WriteModTile(ref i, ref j, writer, ref nextModTile); + } + else + { + skip++; + if (skip == 255) + { + writer.Write(skip); + skip = 0; + } + } + } + while (NextTile(ref i, ref j)); + if (skip > 0) + { + writer.Write(skip); + } + } + + internal static void ReadTileData(BinaryReader reader, Tables tables) + { + int i = 0; + int j = 0; + bool nextModTile = false; + do + { + if (!nextModTile) + { + byte skip = reader.ReadByte(); + while (skip == 255) + { + for (byte k = 0; k < 255; k++) + { + if (!NextTile(ref i, ref j)) + { + return; + } + } + skip = reader.ReadByte(); + } + for (byte k = 0; k < skip; k++) + { + if (!NextTile(ref i, ref j)) + { + return; + } + } + } + else + { + nextModTile = false; + } + ReadModTile(ref i, ref j, tables, reader, ref nextModTile); + } + while (NextTile(ref i, ref j)); + } + + internal static void WriteModTile(ref int i, ref int j, BinaryWriter writer, ref bool nextModTile) + { + Tile tile = Main.tile[i, j]; + byte flags = 0; + byte[] data = new byte[11]; + int index = 1; + if (tile.active() && tile.type >= TileID.Count) + { + flags |= 1; + data[index] = (byte)tile.type; + index++; + data[index] = (byte)(tile.type >> 8); + index++; + if (Main.tileFrameImportant[tile.type]) + { + data[index] = (byte)tile.frameX; + index++; + if (tile.frameX >= 256) + { + flags |= 2; + data[index] = (byte)(tile.frameX >> 8); + index++; + } + data[index] = (byte)tile.frameY; + index++; + if (tile.frameY >= 256) + { + flags |= 4; + data[index] = (byte)(tile.frameY >> 8); + index++; + } + } + if (tile.color() != 0) + { + flags |= 8; + data[index] = tile.color(); + index++; + } + } + if (tile.wall >= WallID.Count) + { + flags |= 16; + data[index] = (byte)tile.wall; + index++; + data[index] = (byte)(tile.wall >> 8); + index++; + if (tile.wallColor() != 0) + { + flags |= 32; + data[index] = tile.wallColor(); + index++; + } + } + int nextI = i; + int nextJ = j; + byte sameCount = 0; + while (NextTile(ref nextI, ref nextJ)) + { + if (tile.isTheSameAs(Main.tile[nextI, nextJ]) && sameCount < 255) + { + sameCount++; + i = nextI; + j = nextJ; + } + else if (HasModData(Main.tile[nextI, nextJ])) + { + flags |= 128; + nextModTile = true; + break; + } + else + { + break; + } + } + if (sameCount > 0) + { + flags |= 64; + data[index] = sameCount; + index++; + } + data[0] = flags; + writer.Write(data, 0, index); + } + + internal static void ReadModTile(ref int i, ref int j, Tables tables, BinaryReader reader, ref bool nextModTile) + { + byte flags; + try + { + flags = reader.ReadByte(); + } + catch + { + ErrorLogger.Log(i + " " + j); + throw; + } + Tile tile = Main.tile[i, j]; + if ((flags & 1) == 1) + { + tile.active(true); + ushort saveType = reader.ReadUInt16(); + tile.type = tables.tiles[saveType]; + if (tables.frameImportant[saveType]) + { + if ((flags & 2) == 2) + { + tile.frameX = reader.ReadInt16(); + } + else + { + tile.frameX = reader.ReadByte(); + } + if ((flags & 4) == 4) + { + tile.frameY = reader.ReadInt16(); + } + else + { + tile.frameY = reader.ReadByte(); + } + } + else + { + tile.frameX = -1; + tile.frameY = -1; + } + if ((flags & 8) == 8) + { + tile.color(reader.ReadByte()); + } + WorldGen.tileCounts[tile.type] += j <= Main.worldSurface ? 5 : 1; + } + if ((flags & 16) == 16) + { + tile.wall = tables.walls[reader.ReadUInt16()]; + if ((flags & 32) == 32) + { + tile.wallColor(reader.ReadByte()); + } + } + if ((flags & 64) == 64) + { + byte sameCount = reader.ReadByte(); + for (byte k = 0; k < sameCount; k++) + { + NextTile(ref i, ref j); + Main.tile[i, j].CopyFrom(tile); + WorldGen.tileCounts[tile.type] += j <= Main.worldSurface ? 5 : 1; + } + } + if ((flags & 128) == 128) + { + nextModTile = true; + } + } + + private static bool HasModData(Tile tile) + { + return (tile.active() && tile.type >= TileID.Count) || tile.wall >= WallID.Count; + } + + private static bool NextTile(ref int i, ref int j) + { + j++; + if (j >= Main.maxTilesY) + { + j = 0; + i++; + if (i >= Main.maxTilesX) + { + return false; + } + } + return true; + } + } +} diff --git a/patches/tModLoader/Terraria.ModLoader.IO/WorldIO.cs b/patches/tModLoader/Terraria.ModLoader.IO/WorldIO.cs new file mode 100644 index 00000000000..0cdd9992f0b --- /dev/null +++ b/patches/tModLoader/Terraria.ModLoader.IO/WorldIO.cs @@ -0,0 +1,249 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.Utilities; + +namespace Terraria.ModLoader.IO +{ + internal static class WorldIO + { + private const byte numByteFlags = 1; + //add near end of Terraria.IO.WorldFile.saveWorld before releasing locks + internal static void WriteModFile(string path, bool isCloudSave) + { + path = Path.ChangeExtension(path, ".twld"); + if (FileUtilities.Exists(path, isCloudSave)) + { + FileUtilities.Copy(path, path + ".bak", isCloudSave, true); + } + byte[] flags; + byte[] data; + using (MemoryStream stream = new MemoryStream()) + { + using (BinaryWriter writer = new BinaryWriter(stream)) + { + flags = WriteModWorld(writer); + writer.Flush(); + data = stream.ToArray(); + } + } + using (MemoryStream stream = new MemoryStream()) + { + using (BinaryWriter writer = new BinaryWriter(stream)) + { + byte limit; + for (limit = (byte)flags.Length; limit > 0; limit--) + { + if (flags[limit - 1] != 0) + { + break; + } + } + writer.Write(limit); + if (limit > 0) + { + writer.Write(flags, 0, limit); + writer.Write(data); + } + writer.Flush(); + data = stream.ToArray(); + } + } + FileUtilities.Write(path, data, data.Length, isCloudSave); + } + //add near end of Terraria.IO.WorldFile.loadWorld before setting failure and success + internal static void ReadModFile(string path, bool isCloudSave) + { + path = Path.ChangeExtension(path, ".twld"); + if (!FileUtilities.Exists(path, isCloudSave)) + { + return; + } + byte[] buffer = FileUtilities.ReadAllBytes(path, isCloudSave); + using (MemoryStream stream = new MemoryStream(buffer)) + { + using (BinaryReader reader = new BinaryReader(stream)) + { + byte limit = reader.ReadByte(); + if (limit == 0) + { + return; + } + byte[] flags = reader.ReadBytes(limit); + if (flags.Length < numByteFlags) + { + Array.Resize(ref flags, numByteFlags); + } + ReadModWorld(flags, reader); + } + } + } + + internal static byte[] WriteModWorld(BinaryWriter writer) + { + byte[] flags = new byte[numByteFlags]; + if (WriteChests(writer)) + { + flags[0] |= 1; + } + if (TileIO.WriteTiles(writer)) + { + flags[0] |= 2; + } + return flags; + } + + internal static void ReadModWorld(byte[] flags, BinaryReader reader) + { + if ((flags[0] & 1) == 1) + { + ReadChests(reader); + } + if ((flags[0] & 2) == 2) + { + TileIO.ReadTiles(reader); + } + } + + internal static bool WriteChests(BinaryWriter writer) + { + short count = 0; + byte[] data; + using (MemoryStream stream = new MemoryStream()) + { + using (BinaryWriter chestWriter = new BinaryWriter(stream)) + { + for (int k = 0; k < 1000; k++) + { + Chest chest = Main.chest[k]; + if (chest != null) + { + if (WriteChest(chest, chestWriter)) + { + count++; + } + } + } + chestWriter.Flush(); + data = stream.ToArray(); + } + } + if (count > 0) + { + writer.Write(count); + writer.Write(data); + return true; + } + return false; + } + + internal static void ReadChests(BinaryReader reader) + { + short count = reader.ReadInt16(); + for (int k = 0; k < count; k++) + { + ReadChest(reader); + } + } + + internal static bool WriteChest(Chest chest, BinaryWriter writer) + { + bool flag; + byte[] data; + using (MemoryStream stream = new MemoryStream()) + { + using (BinaryWriter invWriter = new BinaryWriter(stream)) + { + flag = PlayerIO.WriteInventory(chest.item, invWriter, true); + invWriter.Flush(); + data = stream.ToArray(); + } + } + if (flag) + { + writer.Write(chest.x); + writer.Write(chest.y); + writer.Write(data); + } + return flag; + } + + internal static void ReadChest(BinaryReader reader) + { + int x = reader.ReadInt32(); + int y = reader.ReadInt32(); + int chest = Chest.FindChest(x, y); + if (chest < 0) + { + chest = Chest.CreateChest(x, y); + } + if (chest >= 0) + { + PlayerIO.ReadInventory(Main.chest[chest].item, reader, true); + } + else + { + PlayerIO.ReadInventory(new Item[40], reader, true); + } + } + //add to end of Terraria.IO.WorldFileData.MoveToCloud + internal static void MoveToCloud(string localPath, string cloudPath) + { + localPath = Path.ChangeExtension(localPath, ".twld"); + cloudPath = Path.ChangeExtension(cloudPath, ".twld"); + if (File.Exists(localPath)) + { + FileUtilities.MoveToCloud(localPath, cloudPath); + } + } + + //add to end of Terraria.IO.WorldFileData.MoveToLocal + internal static void MoveToLocal(string cloudPath, string localPath) + { + cloudPath = Path.ChangeExtension(cloudPath, ".twld"); + localPath = Path.ChangeExtension(localPath, ".twld"); + if (FileUtilities.Exists(cloudPath, true)) + { + FileUtilities.MoveToLocal(cloudPath, localPath); + } + } + //in Terraria.Main.DrawMenu in menuMode == 200 add after moving .bak file + internal static void LoadBackup(string path, bool cloudSave) + { + path = Path.ChangeExtension(path, ".twld"); + if (FileUtilities.Exists(path + ".bak", cloudSave)) + { + FileUtilities.Move(path + ".bak", path, cloudSave, true); + } + } + //in Terraria.WorldGen.do_playWorldCallback add this after moving .bak file + internal static void LoadDedServBackup(string path, bool cloudSave) + { + path = Path.ChangeExtension(path, ".twld"); + if (FileUtilities.Exists(path, cloudSave)) + { + FileUtilities.Copy(path, path + ".bad", cloudSave, true); + } + if (FileUtilities.Exists(path + ".bak", cloudSave)) + { + FileUtilities.Copy(path + ".bak", path, cloudSave, true); + FileUtilities.Delete(path + ".bak", cloudSave); + } + } + //in Terraria.WorldGen.do_playWorldCallback add this after returning .bak file + internal static void RevertDedServBackup(string path, bool cloudSave) + { + path = Path.ChangeExtension(path, ".twld"); + if (FileUtilities.Exists(path, cloudSave)) + { + FileUtilities.Copy(path, path + ".bak", cloudSave, true); + } + if (FileUtilities.Exists(path + ".bad", cloudSave)) + { + FileUtilities.Copy(path + ".bad", path, cloudSave, true); + FileUtilities.Delete(path + ".bad", cloudSave); + } + } + } +} diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIBuildMod.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIBuildMod.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIBuildMod.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIBuildMod.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIColorTextPanel.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIColorTextPanel.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIColorTextPanel.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIColorTextPanel.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIErrorMessage.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIErrorMessage.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIErrorMessage.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIErrorMessage.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UILoadMods.cs b/patches/tModLoader/Terraria.ModLoader.UI/UILoadMods.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UILoadMods.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UILoadMods.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UILoadProgress.cs b/patches/tModLoader/Terraria.ModLoader.UI/UILoadProgress.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UILoadProgress.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UILoadProgress.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIMessageBox.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIMessageBox.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIMessageBox.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIMessageBox.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIModItem.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIModItem.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIModItem.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIModItem.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIModSourceItem.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIModSourceItem.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIModSourceItem.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIModSourceItem.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIModSources.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIModSources.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIModSources.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIModSources.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIMods.cs b/patches/tModLoader/Terraria.ModLoader.UI/UIMods.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader.UI/UIMods.cs rename to patches/tModLoader/Terraria.ModLoader.UI/UIMods.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/BuildProperties.cs b/patches/tModLoader/Terraria.ModLoader/BuildProperties.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/BuildProperties.cs rename to patches/tModLoader/Terraria.ModLoader/BuildProperties.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/CraftGroup.cs b/patches/tModLoader/Terraria.ModLoader/CraftGroup.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/CraftGroup.cs rename to patches/tModLoader/Terraria.ModLoader/CraftGroup.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/EquipLoader.cs b/patches/tModLoader/Terraria.ModLoader/EquipLoader.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/EquipLoader.cs rename to patches/tModLoader/Terraria.ModLoader/EquipLoader.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/EquipType.cs b/patches/tModLoader/Terraria.ModLoader/EquipType.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/EquipType.cs rename to patches/tModLoader/Terraria.ModLoader/EquipType.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ErrorLogger.cs b/patches/tModLoader/Terraria.ModLoader/ErrorLogger.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ErrorLogger.cs rename to patches/tModLoader/Terraria.ModLoader/ErrorLogger.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/GlobalItem.cs b/patches/tModLoader/Terraria.ModLoader/GlobalItem.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/GlobalItem.cs rename to patches/tModLoader/Terraria.ModLoader/GlobalItem.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/GlobalNPC.cs b/patches/tModLoader/Terraria.ModLoader/GlobalNPC.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/GlobalNPC.cs rename to patches/tModLoader/Terraria.ModLoader/GlobalNPC.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/GlobalProjectile.cs b/patches/tModLoader/Terraria.ModLoader/GlobalProjectile.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/GlobalProjectile.cs rename to patches/tModLoader/Terraria.ModLoader/GlobalProjectile.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/GlobalTile.cs b/patches/tModLoader/Terraria.ModLoader/GlobalTile.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/GlobalTile.cs rename to patches/tModLoader/Terraria.ModLoader/GlobalTile.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/GlobalWall.cs b/patches/tModLoader/Terraria.ModLoader/GlobalWall.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/GlobalWall.cs rename to patches/tModLoader/Terraria.ModLoader/GlobalWall.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/Interface.cs b/patches/tModLoader/Terraria.ModLoader/Interface.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/Interface.cs rename to patches/tModLoader/Terraria.ModLoader/Interface.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ItemLoader.cs b/patches/tModLoader/Terraria.ModLoader/ItemLoader.cs similarity index 92% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ItemLoader.cs rename to patches/tModLoader/Terraria.ModLoader/ItemLoader.cs index 8c563aeb551..2062f902318 100644 --- a/Patcher/patches/tModLoader/Terraria.ModLoader/ItemLoader.cs +++ b/patches/tModLoader/Terraria.ModLoader/ItemLoader.cs @@ -67,79 +67,6 @@ internal static bool IsModItem(Item item) { return item.type >= ItemID.Count; } - //modify saving in Terraria.IO.WorldFile.SaveChests and Terraria.Player.SavePlayer - //replace netID writes with this - internal static void WriteID(Item item, BinaryWriter writer) - { - if (item.netID >= ItemID.Count) - { - int writeID = Int32.MaxValue; - byte[] data; - using (MemoryStream memoryStream = new MemoryStream()) - { - using (BinaryWriter customWriter = new BinaryWriter(memoryStream)) - { - item.modItem.SaveCustomData(customWriter); - customWriter.Flush(); - data = memoryStream.ToArray(); - } - } - if (data.Length > 0) - { - writeID -= 1; - } - writer.Write(writeID); - writer.Write(item.modItem.mod.Name); - writer.Write(Main.itemName[item.type]); - if (data.Length > 0) - { - writer.Write((short)data.Length); - writer.Write(data); - } - } - else - { - writer.Write(item.netID); - } - } - //modify loading in Terraria.IO.WorldFile.LoadChests and Terraria.Player.LoadPlayer - //replace netDefaults reads with this - //in Terraria.IO.WorldFile.ValidateWorld inside if (num10 > 0) replace fileIO.ReadInt32(); - internal static void ReadID(Item item, BinaryReader reader) - { - int type = reader.ReadInt32(); - if (type >= Int32.MaxValue - 1) - { - bool hasCustomData = type == Int32.MaxValue - 1; - string modName = reader.ReadString(); - string itemName = reader.ReadString(); - Mod mod = ModLoader.GetMod(modName); - if (mod == null) - { - type = 0; - } - else - { - type = mod.ItemType(itemName); - } - item.netDefaults(type); - if (type != 0 && hasCustomData) - { - byte[] data = reader.ReadBytes(reader.ReadInt16()); - using (MemoryStream memoryStream = new MemoryStream(data)) - { - using (BinaryReader customReader = new BinaryReader(memoryStream)) - { - item.modItem.LoadCustomData(customReader); - } - } - } - } - else - { - item.netDefaults(type); - } - } //add to Terraria.Item.Prefix internal static bool MeleePrefix(Item item) { diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/MapLegend.cs b/patches/tModLoader/Terraria.ModLoader/MapLegend.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/MapLegend.cs rename to patches/tModLoader/Terraria.ModLoader/MapLegend.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/Mod.cs b/patches/tModLoader/Terraria.ModLoader/Mod.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/Mod.cs rename to patches/tModLoader/Terraria.ModLoader/Mod.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModDust.cs b/patches/tModLoader/Terraria.ModLoader/ModDust.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModDust.cs rename to patches/tModLoader/Terraria.ModLoader/ModDust.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModItem.cs b/patches/tModLoader/Terraria.ModLoader/ModItem.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModItem.cs rename to patches/tModLoader/Terraria.ModLoader/ModItem.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModLoader.cs b/patches/tModLoader/Terraria.ModLoader/ModLoader.cs similarity index 99% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModLoader.cs rename to patches/tModLoader/Terraria.ModLoader/ModLoader.cs index 23b03fea908..4c220298d5e 100644 --- a/Patcher/patches/tModLoader/Terraria.ModLoader/ModLoader.cs +++ b/patches/tModLoader/Terraria.ModLoader/ModLoader.cs @@ -14,6 +14,8 @@ namespace Terraria.ModLoader { public static class ModLoader { + //change Terraria.Main.versionNumber to include this + public static string version = "tModLoader v0.4"; //change Terraria.Main.SavePath to use "ModLoader" folder public static readonly string ModPath = Main.SavePath + Path.DirectorySeparatorChar + "Mods"; public static readonly string ModSourcePath = Main.SavePath + Path.DirectorySeparatorChar + "Mod Sources"; diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModNPC.cs b/patches/tModLoader/Terraria.ModLoader/ModNPC.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModNPC.cs rename to patches/tModLoader/Terraria.ModLoader/ModNPC.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModProjectile.cs b/patches/tModLoader/Terraria.ModLoader/ModProjectile.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModProjectile.cs rename to patches/tModLoader/Terraria.ModLoader/ModProjectile.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModProperties.cs b/patches/tModLoader/Terraria.ModLoader/ModProperties.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModProperties.cs rename to patches/tModLoader/Terraria.ModLoader/ModProperties.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModRecipe.cs b/patches/tModLoader/Terraria.ModLoader/ModRecipe.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModRecipe.cs rename to patches/tModLoader/Terraria.ModLoader/ModRecipe.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModTile.cs b/patches/tModLoader/Terraria.ModLoader/ModTile.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModTile.cs rename to patches/tModLoader/Terraria.ModLoader/ModTile.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ModWall.cs b/patches/tModLoader/Terraria.ModLoader/ModWall.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ModWall.cs rename to patches/tModLoader/Terraria.ModLoader/ModWall.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/NPCLoader.cs b/patches/tModLoader/Terraria.ModLoader/NPCLoader.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/NPCLoader.cs rename to patches/tModLoader/Terraria.ModLoader/NPCLoader.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/ProjectileLoader.cs b/patches/tModLoader/Terraria.ModLoader/ProjectileLoader.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/ProjectileLoader.cs rename to patches/tModLoader/Terraria.ModLoader/ProjectileLoader.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/TileLoader.cs b/patches/tModLoader/Terraria.ModLoader/TileLoader.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/TileLoader.cs rename to patches/tModLoader/Terraria.ModLoader/TileLoader.cs diff --git a/Patcher/patches/tModLoader/Terraria.ModLoader/WallLoader.cs b/patches/tModLoader/Terraria.ModLoader/WallLoader.cs similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ModLoader/WallLoader.cs rename to patches/tModLoader/Terraria.ModLoader/WallLoader.cs diff --git a/Patcher/patches/tModLoader/Terraria.ObjectData/TileObjectData.cs.patch b/patches/tModLoader/Terraria.ObjectData/TileObjectData.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria.ObjectData/TileObjectData.cs.patch rename to patches/tModLoader/Terraria.ObjectData/TileObjectData.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria.UI/ItemSlot.cs.patch b/patches/tModLoader/Terraria.UI/ItemSlot.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria.UI/ItemSlot.cs.patch rename to patches/tModLoader/Terraria.UI/ItemSlot.cs.patch diff --git a/patches/tModLoader/Terraria.Utilities/PlatformUtilties.cs.patch b/patches/tModLoader/Terraria.Utilities/PlatformUtilties.cs.patch new file mode 100644 index 00000000000..6a095c75803 --- /dev/null +++ b/patches/tModLoader/Terraria.Utilities/PlatformUtilties.cs.patch @@ -0,0 +1,13 @@ +--- src/Terraria\Terraria.Utilities\PlatformUtilties.cs ++++ src/tModLoader\Terraria.Utilities\PlatformUtilties.cs +@@ -46,7 +46,8 @@ + public static string GetStoragePath() + { + string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "My Games"); +- return Path.Combine(path, "Terraria"); ++ path = Path.Combine(path, "Terraria"); ++ return Path.Combine(path, "ModLoader"); + } + } + } + diff --git a/Patcher/patches/tModLoader/Terraria.csproj.patch b/patches/tModLoader/Terraria.csproj.patch similarity index 82% rename from Patcher/patches/tModLoader/Terraria.csproj.patch rename to patches/tModLoader/Terraria.csproj.patch index a9e2e23e666..672a87fc085 100644 --- a/Patcher/patches/tModLoader/Terraria.csproj.patch +++ b/patches/tModLoader/Terraria.csproj.patch @@ -1,28 +1,22 @@ --- src/Terraria\Terraria.csproj +++ src/tModLoader\Terraria.csproj -@@ -1,7 +1,7 @@ - - - -- {3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5} -+ {F289741C-268A-484B-9216-822EBBA1A211} - Debug - x86 - WinExe -@@ -32,6 +32,9 @@ +@@ -31,6 +31,9 @@ + - true CLIENT + + + Icon.ico - -@@ -239,6 +242,43 @@ + +@@ -238,6 +241,47 @@ ++ ++ ++ + + + @@ -57,13 +51,14 @@ + + + ++ + + + -@@ -384,5 +424,8 @@ +@@ -384,5 +428,8 @@ diff --git a/Patcher/patches/tModLoader/Terraria/Dust.cs.patch b/patches/tModLoader/Terraria/Dust.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria/Dust.cs.patch rename to patches/tModLoader/Terraria/Dust.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria/Item.cs.patch b/patches/tModLoader/Terraria/Item.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria/Item.cs.patch rename to patches/tModLoader/Terraria/Item.cs.patch diff --git a/patches/tModLoader/Terraria/Lang.cs.patch b/patches/tModLoader/Terraria/Lang.cs.patch new file mode 100644 index 00000000000..4b5fd58a4ac --- /dev/null +++ b/patches/tModLoader/Terraria/Lang.cs.patch @@ -0,0 +1,27 @@ +--- src/Terraria\Terraria\Lang.cs ++++ src/tModLoader\Terraria\Lang.cs +@@ -1,4 +1,5 @@ + using System; ++using Terraria.ModLoader; + + #if CLIENT + using Terraria.Map; +@@ -17,7 +18,7 @@ + public static string[] dt = new string[4]; + public static string[] chestType = new string[52]; + public static string[] dresserType = new string[28]; +- public static string[] mapLegend; ++ public static MapLegend mapLegend; + public static string[] prefix = new string[84]; + public static string the; + +@@ -32679,7 +32680,7 @@ + #if CLIENT + if (Lang.mapLegend == null) + { +- Lang.mapLegend = new string[MapHelper.LookupCount()]; ++ Lang.mapLegend = new MapLegend(MapHelper.LookupCount()); + } + Lang.mapLegend[MapHelper.TileToLookup(4, 0)] = "Torch"; + Lang.mapLegend[MapHelper.TileToLookup(4, 1)] = "Torch"; + diff --git a/Patcher/patches/tModLoader/Terraria/Lighting.cs.patch b/patches/tModLoader/Terraria/Lighting.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria/Lighting.cs.patch rename to patches/tModLoader/Terraria/Lighting.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria/Main.cs.patch b/patches/tModLoader/Terraria/Main.cs.patch similarity index 67% rename from Patcher/patches/tModLoader/Terraria/Main.cs.patch rename to patches/tModLoader/Terraria/Main.cs.patch index c7d76e53eb1..7a6f78cface 100644 --- a/Patcher/patches/tModLoader/Terraria/Main.cs.patch +++ b/patches/tModLoader/Terraria/Main.cs.patch @@ -1,43 +1,24 @@ --- src/Terraria\Terraria\Main.cs +++ src/tModLoader\Terraria\Main.cs -@@ -31,6 +31,7 @@ +@@ -31,6 +31,8 @@ using Terraria.Initializers; using Terraria.IO; using Terraria.Map; +using Terraria.ModLoader; ++using Terraria.ModLoader.IO; using Terraria.Net; using Terraria.ObjectData; using Terraria.Social; -@@ -39,17 +40,9 @@ - using Terraria.Utilities; - using Terraria.World.Generation; - --#if SERVER --using Terraria.Server; --#endif - namespace Terraria - { -- #if CLIENT - public class Main : Game -- --#else -- public class Main : Terraria.Server.Game --#endif - { - public delegate void OnPlayerSelected(PlayerFileData player); - -@@ -1258,7 +1251,9 @@ - Path.DirectorySeparatorChar, - "My Games", - Path.DirectorySeparatorChar, -- "Terraria" -+ "Terraria", -+ Path.DirectorySeparatorChar, -+ "ModLoader" - }); - public static string WorldPath = Main.SavePath + Path.DirectorySeparatorChar + "Worlds"; - public static string CloudWorldPath = "worlds"; -@@ -1921,7 +1916,7 @@ +@@ -121,7 +123,7 @@ + public bool unityMouseOver; + public static Main instance; + public static int curRelease = 156; +- public static string versionNumber = "v1.3.0.8"; ++ public static string versionNumber = "v1.3.0.8" + Environment.NewLine + ModLoader.ModLoader.version; + public static string versionNumber2 = "v1.3.0.8"; + public static string SavePath = Program.LaunchParameters.ContainsKey("-savedirectory") ? Program.LaunchParameters["-savedirectory"] : PlatformUtilties.GetStoragePath(); + public static Vector2 destroyerHB = new Vector2(0f, 0f); +@@ -1910,7 +1912,7 @@ private int selectedMenu2 = -1; public static int selectedPlayer = 0; public static int selectedWorld = 0; @@ -46,127 +27,10 @@ public static int menuSkip = 0; private static Item cpItem = new Item(); public int textBlinkerCount; -@@ -2479,13 +2474,11 @@ - Main.mouseColor.R = Main.Configuration.Get("MouseColorR", Main.mouseColor.R); - Main.mouseColor.G = Main.Configuration.Get("MouseColorG", Main.mouseColor.G); - Main.mouseColor.B = Main.Configuration.Get("MouseColorB", Main.mouseColor.B); --#if CLIENT - if (Main.screenMaximized) - { - Form form = (Form)Control.FromHandle(Main.instance.Window.Handle); - form.WindowState = FormWindowState.Maximized; - } --#endif - Main.SetDisplayMode(preferredBackBufferWidth, preferredBackBufferHeight, fullscreen); - int num = 0; - Main.Configuration.Get("LastLaunchedVersion", ref num); -@@ -2557,10 +2550,8 @@ - } - if (num >= 91 && binaryReader.ReadBoolean()) - { --#if CLIENT - Form form = (Form)Control.FromHandle(base.Window.Handle); - form.WindowState = FormWindowState.Maximized; --#endif - } - if (num >= 4) - { -@@ -3964,21 +3955,13 @@ - public Main() - { - Main.instance = this; --#if CLIENT - Main.graphics = new GraphicsDeviceManager((Game)this); --#if DEBUG -- base.Content.RootDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Content"); --#else - base.Content.RootDirectory = "Content"; --#endif --#endif - } - - protected void SetTitle() - { --#if CLIENT - base.Window.Title = Lang.title(); --#endif - } - - public static void InitLifeBytes() -@@ -4034,9 +4017,6 @@ - - protected override void Initialize() - { --#if SERVER -- Main.netMode = 2; --#endif - Main.LocalFavoriteData.Load(); - Main.CloudFavoritesData.Load(); - TileObjectData.Initialize(); -@@ -4047,14 +4027,9 @@ - ItemRarity.Initialize(); - TileEntity.InitializeAll(); - Main.InitializeItemAnimations(); --#if CLIENT - Lighting.Initialize(false); - MapHelper.Initialize(); - TimeLogger.Initialize(); --#else -- Mount.Initialize(); -- Minecart.Initialize(); --#endif - WorldGen.RandomizeBackgrounds(); - WorldGen.RandomizeCaveBackgrounds(); - WorldGen.RandomizeMoonState(); -@@ -6388,20 +6363,17 @@ - Main.ActivePlayerFileData.StartPlayTimer(); - Player.EnterWorld(Main.player[Main.myPlayer]); - } --#if CLIENT - else - { - IntPtr systemMenu = Main.GetSystemMenu(base.Window.Handle, false); - int menuItemCount = Main.GetMenuItemCount(systemMenu); - Main.RemoveMenu(systemMenu, menuItemCount - 1, 1024); - } --#endif - if (Main.dedServ) - { - return; - } - Main.clientUUID = Guid.NewGuid().ToString(); --#if CLIENT - keyBoardInput.newKeyEvent += delegate(char keyStroke) - { - if (Main.keyCount < 10) -@@ -6411,7 +6383,6 @@ - Main.keyCount++; - } - }; --#endif - base.Initialize(); - base.Window.AllowUserResizing = true; - this.OpenSettings(); -@@ -6438,14 +6409,12 @@ - this.OpenRecent(); - Star.SpawnStars(); - WorldGen.RandomizeWeather(); --#if CLIENT - this._achievements = new AchievementManager(); - AchievementInitializer.Load(); - DyeInitializer.Load(); - ScreenEffectInitializer.Load(); - ChatInitializer.Load(); - AchievementCompleteUI.Initialize(); --#endif - foreach (DisplayMode current in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) - { - if (current.Width >= Main.minScreenW && current.Height >= Main.minScreenH && current.Width <= Main.maxScreenW && current.Height <= Main.maxScreenH) -@@ -10593,12 +10562,22 @@ +@@ -10594,6 +10596,18 @@ protected override void Update(GameTime gameTime) { --#if CLIENT + try + { + do_Update(gameTime); @@ -179,15 +43,10 @@ + + protected void do_Update(GameTime gameTime) + { + #if CLIENT if (Main.OnTick != null) { - Main.OnTick(); - } --#endif - if (Main._largeMethodFix) - { - Main._largeMethodFix = false; -@@ -11272,6 +11251,7 @@ +@@ -11267,6 +11281,7 @@ Main.wallFrameCounter[144] = 0; } } @@ -195,7 +54,7 @@ Main.tileFrameCounter[12]++; if (Main.tileFrameCounter[12] > 5) { -@@ -11747,6 +11727,7 @@ +@@ -11742,6 +11757,7 @@ Main.tileFrame[410] = 0; } } @@ -203,140 +62,7 @@ Main.CritterCages(); Main.UpdateDrawAnimations(); if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F10) && !Main.chatMode && !Main.editSign && !Main.editChest) -@@ -12696,7 +12677,6 @@ - - public static string GetInputText(string oldString) - { --#if CLIENT - if (!Main.hasFocus) - { - return oldString; -@@ -12719,12 +12699,12 @@ - else if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.X)) - { - Thread thread = new Thread((ThreadStart)delegate -- { -- if (oldString.Length > 0) -- { -- Clipboard.SetText(oldString); -- } -- }); -+ { -+ if (oldString.Length > 0) -+ { -+ Clipboard.SetText(oldString); -+ } -+ }); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - while (thread.IsAlive) -@@ -12735,12 +12715,12 @@ - else if ((Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C)) || (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert))) - { - Thread thread2 = new Thread((ThreadStart)delegate -- { -- if (oldString.Length > 0) -- { -- Clipboard.SetText(oldString); -- } -- }); -+ { -+ if (oldString.Length > 0) -+ { -+ Clipboard.SetText(oldString); -+ } -+ }); - thread2.SetApartmentState(ApartmentState.STA); - thread2.Start(); - while (thread2.IsAlive) -@@ -12750,17 +12730,17 @@ - else if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V)) - { - Thread thread3 = new Thread((ThreadStart)delegate -- { -- string text2 = Clipboard.GetText(); -- for (int l = 0; l < text2.Length; l++) -- { -- if (text2[l] < ' ' || text2[l] == '\u007f') -- { -- text2 = text2.Replace(string.Concat(text2[l--]), ""); -- } -- } -- newKeys += text2; -- }); -+ { -+ string text2 = Clipboard.GetText(); -+ for (int l = 0; l < text2.Length; l++) -+ { -+ if (text2[l] < ' ' || text2[l] == '\u007f') -+ { -+ text2 = text2.Replace(string.Concat(text2[l--]), ""); -+ } -+ } -+ newKeys += text2; -+ }); - thread3.SetApartmentState(ApartmentState.STA); - thread3.Start(); - while (thread3.IsAlive) -@@ -12775,12 +12755,12 @@ - if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Delete)) - { - Thread thread4 = new Thread((ThreadStart)delegate -- { -- if (oldString.Length > 0) -- { -- Clipboard.SetText(oldString); -- } -- }); -+ { -+ if (oldString.Length > 0) -+ { -+ Clipboard.SetText(oldString); -+ } -+ }); - thread4.SetApartmentState(ApartmentState.STA); - thread4.Start(); - while (thread4.IsAlive) -@@ -12791,17 +12771,17 @@ - if (Main.inputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert) && !Main.oldInputText.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Insert)) - { - Thread thread5 = new Thread((ThreadStart)delegate -- { -- string text2 = Clipboard.GetText(); -- for (int l = 0; l < text2.Length; l++) -- { -- if (text2[l] < ' ' || text2[l] == '\u007f') -- { -- text2 = text2.Replace(string.Concat(text2[l--]), ""); -- } -- } -- newKeys += text2; -- }); -+ { -+ string text2 = Clipboard.GetText(); -+ for (int l = 0; l < text2.Length; l++) -+ { -+ if (text2[l] < ' ' || text2[l] == '\u007f') -+ { -+ text2 = text2.Replace(string.Concat(text2[l--]), ""); -+ } -+ } -+ newKeys += text2; -+ }); - thread5.SetApartmentState(ApartmentState.STA); - thread5.Start(); - while (thread5.IsAlive) -@@ -12871,9 +12851,6 @@ - } - } - return text; --#else -- return ""; --#endif - } - - public void MouseText(string cursorText, int rare = 0, byte diff = 0) -@@ -14281,6 +14258,7 @@ +@@ -14236,6 +14252,7 @@ { effects = SpriteEffects.FlipHorizontally; } @@ -344,7 +70,7 @@ Microsoft.Xna.Framework.Color color = Lighting.GetColor(j, i); int num11 = 0; int num12 = 16; -@@ -14520,6 +14498,7 @@ +@@ -14475,6 +14492,7 @@ { num11 = 2; } @@ -352,7 +78,7 @@ int num14 = 0; if (tile.halfBrick()) { -@@ -14696,6 +14675,12 @@ +@@ -14651,6 +14669,12 @@ } num16 = k * 18; num15 = 0; @@ -365,7 +91,7 @@ } if (type == 373 || type == 374 || type == 375) { -@@ -17959,6 +17944,7 @@ +@@ -17914,6 +17938,7 @@ int num281 = 0; Main.spriteBatch.Draw(texture2D, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num280, (float)(i * 16 - (int)Main.screenPosition.Y + num11 + num281)) + zero, new Microsoft.Xna.Framework.Rectangle?(empty), color2, 0f, default(Vector2), 1f, effects, 0f); } @@ -373,38 +99,7 @@ } } } -@@ -19253,23 +19239,25 @@ - float num4; - switch (m) - { -+ case 0: - default: - num3 = num2; - num4 = 0f; -- break; -+ goto IL_7AF; - case 1: - num3 = -num2; - num4 = 0f; -- break; -+ goto IL_7AF; - case 2: - num3 = 0f; - num4 = num2; -- break; -+ goto IL_7AF; - case 3: - num3 = 0f; - num4 = -num2; -- break; -- } -+ goto IL_7AF; -+ } -+ IL_7AF: - position = new Vector2(player.position.X + num3, player.position.Y + player.gfxOffY + num4); - this.DrawPlayer(player, position, player.fullRotation, player.fullRotationOrigin, player.ghostFade); - } -@@ -19347,7 +19335,7 @@ +@@ -19304,7 +19329,7 @@ { try { @@ -413,7 +108,7 @@ { if (Main.npc[i].type == 125 || Main.npc[i].type == 126) { -@@ -26543,7 +26531,7 @@ +@@ -26500,7 +26525,7 @@ for (int i = 0; i < 16 + drawPlayer.extraAccessorySlots * 2; i++) { int num2 = i % 10; @@ -422,7 +117,7 @@ { byte arg_81_0 = drawPlayer.dye[num2].dye; } -@@ -26596,7 +26584,8 @@ +@@ -26553,7 +26578,8 @@ { flag2 = true; } @@ -432,7 +127,7 @@ { Main.spriteBatch.Draw(Main.playerTextures[skinVariant, 0], new Vector2(drawPlayer.position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2), drawPlayer.position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f) + drawPlayer.headPosition + vector, new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color4, drawPlayer.headRotation, vector, Scale, spriteEffects, 0f); Main.spriteBatch.Draw(Main.playerTextures[skinVariant, 1], new Vector2(drawPlayer.position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2), drawPlayer.position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f) + drawPlayer.headPosition + vector, new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color, drawPlayer.headRotation, vector, Scale, spriteEffects, 0f); -@@ -26709,7 +26698,7 @@ +@@ -26666,7 +26692,7 @@ value4.Draw(Main.spriteBatch); Main.pixelShader.CurrentTechnique.Passes[0].Apply(); } @@ -441,7 +136,7 @@ { DrawData value5 = new DrawData(Main.armorHeadTexture[drawPlayer.head], new Vector2(drawPlayer.position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2), drawPlayer.position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f) + drawPlayer.headPosition + vector, new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color5, drawPlayer.headRotation, vector, Scale, spriteEffects, 0); GameShaders.Armor.Apply(shaderId, drawPlayer, new DrawData?(value5)); -@@ -26729,7 +26718,7 @@ +@@ -26686,7 +26712,7 @@ value6.Draw(Main.spriteBatch); Main.pixelShader.CurrentTechnique.Passes[0].Apply(); } @@ -450,7 +145,7 @@ { DrawData value7; if (drawPlayer.face == 7) -@@ -26806,6 +26795,7 @@ +@@ -26763,6 +26789,7 @@ { flag5 = true; } @@ -458,7 +153,7 @@ bool flag6 = false; if (drawPlayer.face == 4 || drawPlayer.face == 3 || drawPlayer.face == 2) { -@@ -26854,47 +26844,47 @@ +@@ -26811,47 +26838,47 @@ int num8 = i % 10; if (drawPlayer.dye[num8] != null && drawPlayer.armor[i].type > 0 && drawPlayer.armor[i].stack > 0 && (i / 10 >= 1 || !drawPlayer.hideVisual[num8] || drawPlayer.armor[i].wingSlot > 0 || drawPlayer.armor[i].type == 934)) { @@ -517,7 +212,7 @@ { shader12 = (int)drawPlayer.dye[num8].dye; } -@@ -27919,9 +27909,9 @@ +@@ -27876,9 +27903,9 @@ Main.playerDrawData.Add(value); } } @@ -530,7 +225,7 @@ { int num54 = drawPlayer.bodyFrame.Y / 56; if (num54 < 1 || num54 > 5) -@@ -28161,7 +28151,7 @@ +@@ -28118,7 +28145,7 @@ goto IL_5B88; } IL_5852: @@ -539,7 +234,7 @@ { if (!drawPlayer.invis) { -@@ -28188,7 +28178,7 @@ +@@ -28145,7 +28172,7 @@ goto IL_5C63; } IL_5B88: @@ -548,7 +243,7 @@ { value = new DrawData(Main.accShoesTexture[(int)drawPlayer.shoe], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.legFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.legFrame.Height + 4f))) + drawPlayer.legPosition + vector2, new Microsoft.Xna.Framework.Rectangle?(drawPlayer.legFrame), color14, drawPlayer.legRotation, vector2, 1f, spriteEffects, 0); value.shader = shader6; -@@ -28199,12 +28189,12 @@ +@@ -28156,12 +28183,12 @@ goto IL_5852; } IL_5C63: @@ -563,7 +258,7 @@ { Microsoft.Xna.Framework.Rectangle bodyFrame2 = drawPlayer.bodyFrame; int num61 = num2; -@@ -28260,13 +28250,13 @@ +@@ -28217,13 +28244,13 @@ value = new DrawData(Main.playerTextures[skinVariant, 5], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f))) + drawPlayer.bodyPosition + new Vector2((float)(drawPlayer.bodyFrame.Width / 2), (float)(drawPlayer.bodyFrame.Height / 2)), new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color5, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); Main.playerDrawData.Add(value); } @@ -579,7 +274,7 @@ { Microsoft.Xna.Framework.Rectangle legFrame = drawPlayer.legFrame; if (legFrame.Y >= 1064) -@@ -28277,13 +28267,13 @@ +@@ -28234,13 +28261,13 @@ value.shader = shader7; Main.playerDrawData.Add(value); } @@ -595,7 +290,7 @@ { value = new DrawData(Main.playerTextures[skinVariant, 0], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f))) + drawPlayer.headPosition + vector3, new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color4, drawPlayer.headRotation, vector3, 1f, spriteEffects, 0); Main.playerDrawData.Add(value); -@@ -28350,7 +28340,7 @@ +@@ -28307,7 +28334,7 @@ value.shader = num6; Main.playerDrawData.Add(value); } @@ -604,7 +299,7 @@ { if (!drawPlayer.invis || (drawPlayer.head != 39 && drawPlayer.head != 38)) { -@@ -28412,7 +28402,7 @@ +@@ -28369,7 +28396,7 @@ Main.playerDrawData.Add(value); } } @@ -613,7 +308,7 @@ { if (drawPlayer.face == 7) { -@@ -28451,7 +28441,7 @@ +@@ -28408,7 +28435,7 @@ Main.playerDrawData.Add(value); } } @@ -622,7 +317,7 @@ { value = new DrawData(Main.accShieldTexture[(int)drawPlayer.shield], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f))) + drawPlayer.bodyPosition + new Vector2((float)(drawPlayer.bodyFrame.Width / 2), (float)(drawPlayer.bodyFrame.Height / 2)), new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color12, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); value.shader = shader8; -@@ -28660,7 +28650,7 @@ +@@ -28617,7 +28644,7 @@ } } } @@ -631,7 +326,7 @@ { Microsoft.Xna.Framework.Rectangle bodyFrame4 = drawPlayer.bodyFrame; int num82 = num2; -@@ -28703,7 +28693,7 @@ +@@ -28660,7 +28687,7 @@ value = new DrawData(Main.playerTextures[skinVariant, 13], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f))) + drawPlayer.bodyPosition + new Vector2((float)(drawPlayer.bodyFrame.Width / 2), (float)(drawPlayer.bodyFrame.Height / 2)), new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color7, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); Main.playerDrawData.Add(value); } @@ -640,7 +335,7 @@ { value = new DrawData(Main.accHandsOnTexture[(int)drawPlayer.handon], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f))) + drawPlayer.bodyPosition + new Vector2((float)(drawPlayer.bodyFrame.Width / 2), (float)(drawPlayer.bodyFrame.Height / 2)), new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color12, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); value.shader = shader2; -@@ -28727,7 +28717,7 @@ +@@ -28684,7 +28711,7 @@ { num = Main.playerDrawData.Count; } @@ -649,7 +344,7 @@ { value = new DrawData(Main.accFrontTexture[(int)drawPlayer.front], new Vector2((float)((int)(Position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2) + (float)(drawPlayer.width / 2))), (float)((int)(Position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f))) + drawPlayer.bodyPosition + new Vector2((float)(drawPlayer.bodyFrame.Width / 2), (float)(drawPlayer.bodyFrame.Height / 2)), new Microsoft.Xna.Framework.Rectangle?(drawPlayer.bodyFrame), color12, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); value.shader = shader5; -@@ -28915,6 +28905,11 @@ +@@ -28872,6 +28899,11 @@ float scale = 1f; Microsoft.Xna.Framework.Color alpha = item.GetAlpha(color); ItemSlot.GetItemLight(ref alpha, ref scale, item, false); @@ -661,7 +356,7 @@ float num4 = (float)(item.height - Main.itemTexture[item.type].Height); float num5 = (float)(item.width / 2 - Main.itemTexture[item.type].Width / 2); if (item.type >= 71 && item.type <= 74) -@@ -28934,6 +28929,7 @@ +@@ -28891,6 +28923,7 @@ int num7 = Main.coinTexture[num6].Height / 8; num5 = (float)(item.width / 2 - Main.coinTexture[num6].Width / 2); Main.spriteBatch.Draw(Main.coinTexture[num6], new Vector2(item.position.X - Main.screenPosition.X + (float)(width / 2) + num5, item.position.Y - Main.screenPosition.Y + (float)(num7 / 2) + num4), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, Main.itemFrame[whoami] * num7 + 1, Main.itemTexture[item.type].Width, num7)), alpha, rotation, new Vector2((float)(width / 2), (float)(num7 / 2)), scale, SpriteEffects.None, 0f); @@ -669,7 +364,7 @@ return; } if (ItemID.Sets.NebulaPickup[item.type]) -@@ -28952,6 +28948,7 @@ +@@ -28909,6 +28942,7 @@ num5 = (float)(item.width / 2 - rectangle.Width / 2); num4 = (float)(item.height - rectangle.Height); Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(rectangle.Width / 2) + num5, item.position.Y - Main.screenPosition.Y + (float)(rectangle.Height / 2) + num4), new Microsoft.Xna.Framework.Rectangle?(rectangle), alpha, rotation, rectangle.Size() / 2f, scale, SpriteEffects.None, 0f); @@ -677,7 +372,7 @@ return; } if (ItemID.Sets.AnimatesAsSoul[item.type]) -@@ -28970,11 +28967,19 @@ +@@ -28927,11 +28961,19 @@ num5 = (float)(item.width / 2 - rectangle2.Width / 2); num4 = (float)(item.height - rectangle2.Height); Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(rectangle2.Width / 2) + num5, item.position.Y - Main.screenPosition.Y + (float)(rectangle2.Height / 2) + num4), new Microsoft.Xna.Framework.Rectangle?(rectangle2), alpha, rotation, rectangle2.Size() / 2f, scale, SpriteEffects.None, 0f); @@ -697,7 +392,7 @@ return; } Main.spriteBatch.Draw(Main.itemTexture[item.type], new Vector2(item.position.X - Main.screenPosition.X + (float)(Main.itemTexture[item.type].Width / 2) + num5, item.position.Y - Main.screenPosition.Y + (float)(Main.itemTexture[item.type].Height / 2) + num4 + 2f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 0, Main.itemTexture[item.type].Width, Main.itemTexture[item.type].Height)), alpha, rotation, new Vector2((float)(Main.itemTexture[item.type].Width / 2), (float)(Main.itemTexture[item.type].Height / 2)), scale, SpriteEffects.None, 0f); -@@ -28986,6 +28991,7 @@ +@@ -28943,6 +28985,7 @@ { Main.spriteBatch.Draw(Main.glowMaskTexture[(int)item.glowMask], new Vector2(item.position.X - Main.screenPosition.X + (float)(Main.itemTexture[item.type].Width / 2) + num5, item.position.Y - Main.screenPosition.Y + (float)(Main.itemTexture[item.type].Height / 2) + num4 + 2f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 0, Main.itemTexture[item.type].Width, Main.itemTexture[item.type].Height)), new Microsoft.Xna.Framework.Color(250, 250, 250, item.alpha), rotation, new Vector2((float)(Main.itemTexture[item.type].Width / 2), (float)(Main.itemTexture[item.type].Height / 2)), scale, SpriteEffects.None, 0f); } @@ -705,7 +400,7 @@ } protected void DrawRain() -@@ -29139,6 +29145,11 @@ +@@ -29096,6 +29139,11 @@ if (dust.type == 213) { scale = 1f; @@ -717,7 +412,7 @@ } Main.spriteBatch.Draw(Main.dustTexture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), color5, dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f); if (dust.color != default(Microsoft.Xna.Framework.Color)) -@@ -31774,7 +31785,7 @@ +@@ -31731,7 +31779,7 @@ else { num61++; @@ -726,7 +421,7 @@ num62++; } } -@@ -32025,6 +32036,14 @@ +@@ -31982,6 +32030,14 @@ else if (Main.recipe[Main.availableRecipe[Main.focusRecipe]].anyPressurePlate && Main.recipe[Main.availableRecipe[Main.focusRecipe]].requiredItem[num72].type == 542) { Main.toolTip.name = Lang.misc[37] + " " + Lang.misc[38]; @@ -741,7 +436,7 @@ } if (Main.recipe[Main.availableRecipe[Main.focusRecipe]].requiredItem[num72].stack > 1) { -@@ -35598,7 +35617,7 @@ +@@ -35555,7 +35611,7 @@ } else { @@ -750,17 +445,15 @@ } flag10 = true; } -@@ -36418,9 +36437,7 @@ - protected void QuitGame() - { - Main.SaveSettings(); --#if CLIENT - SocialAPI.Shutdown(); --#endif - base.Exit(); - } - -@@ -37342,6 +37359,7 @@ +@@ -37161,6 +37217,7 @@ + if (FileUtilities.Exists(Main.worldPathName + ".bak", Main.ActiveWorldFileData.IsCloudSave)) + { + FileUtilities.Move(Main.worldPathName + ".bak", Main.worldPathName, Main.ActiveWorldFileData.IsCloudSave, true); ++ WorldIO.LoadBackup(Main.worldPathName, Main.ActiveWorldFileData.IsCloudSave); + Main.PlaySound(10, -1, -1, 1); + WorldGen.playWorld(); + Main.menuMode = 10; +@@ -37299,6 +37356,7 @@ Main.menuMode = 888; } num9++; @@ -768,7 +461,7 @@ array9[num9] = Lang.menu[14]; if (this.selectedMenu == num9) { -@@ -39051,6 +39069,10 @@ +@@ -39008,6 +39066,10 @@ Main.PlaySound(10, -1, -1, 1); WorldGen.setWorldSize(); } @@ -779,7 +472,7 @@ } } } -@@ -43448,7 +43470,7 @@ +@@ -43405,7 +43467,7 @@ } else { @@ -788,46 +481,36 @@ } } float num103 = (num16 * 0.25f * 2f + 1f) / 3f; -@@ -45979,12 +46001,17 @@ +@@ -45924,7 +45986,7 @@ tile = new Tile(); Main.tile[j, i] = tile; } - byte wall = tile.wall; + ushort wall = tile.wall; - if (tile.wall > 0 && !this.FullTile(j, i)) + if (wall > 0 && !this.FullTile(j, i)) { - this.LoadWall((int)tile.wall); Microsoft.Xna.Framework.Color color = Lighting.GetColor(j, i); - int num9 = (int)(Main.wallFrame[(int)wall] * 180); -+ if (!WallLoader.PreDraw(j, i, wall, Main.spriteBatch)) -+ { -+ WallLoader.PostDraw(j, i, wall, Main.spriteBatch); -+ continue; -+ } - if (Lighting.lightMode < 2 && !Main.wallLight[(int)tile.wall] && (tile.wall < 88 || tile.wall > 93) && !WorldGen.SolidTile(tile)) +@@ -45932,6 +45994,11 @@ { - Texture2D texture; -@@ -46072,6 +46099,7 @@ - Main.spriteBatch.Draw(Main.wallOutlineTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)(i * 16 - (int)Main.screenPosition.Y + 14)) + zero, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 14, 16, 2)), Lighting.GetColor(j, i), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + this.LoadWall((int)wall); + int num8 = (int)(Main.wallFrame[(int)wall] * 180); ++ if (!WallLoader.PreDraw(j, i, wall, Main.spriteBatch)) ++ { ++ WallLoader.PostDraw(j, i, wall, Main.spriteBatch); ++ continue; ++ } + if (Lighting.lightMode < 2 && !Main.wallLight[(int)wall] && (tile.wall < 88 || tile.wall > 93) && !WorldGen.SolidTile(tile)) + { + Texture2D texture; +@@ -46003,6 +46070,7 @@ + Main.spriteBatch.Draw(Main.wallOutlineTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)(i * 16 - (int)Main.screenPosition.Y + 14)) + zero, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 14, 16, 2)), color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } } ++ WallLoader.PostDraw(j, i, wall, Main.spriteBatch); } -+ WallLoader.PostDraw(j, i, wall, Main.spriteBatch); - } - } - } -@@ -48827,7 +48855,6 @@ - - private static void CheckMonoliths() - { --#if CLIENT - bool flag = Main.player[Main.myPlayer].ZoneTowerVortex || Main.player[Main.myPlayer].ZoneTowerNebula || Main.player[Main.myPlayer].ZoneTowerStardust || Main.player[Main.myPlayer].ZoneTowerSolar; - for (int i = 0; i < Main.MonolithFilterNames.Length; i++) - { -@@ -48854,10 +48881,22 @@ } } - } --#endif +@@ -48790,6 +48858,19 @@ } protected override void Draw(GameTime gameTime) @@ -847,30 +530,4 @@ { if (Main._drawCycleCounter == 0uL) { -@@ -48903,9 +48942,7 @@ - { - Main.maxQ = true; - } --#if CLIENT - this.UpdateDisplaySettings(); --#endif - Main.drawTime++; - Main.screenLastPosition = Main.screenPosition; - if (Main.stackSplit == 0) -@@ -51831,7 +51868,6 @@ - Main.UpdateSundial(); - Main.time += (double)Main.dayRate; - CultistRitual.UpdateTime(); --#if CLIENT - if (NPC.MoonLordCountdown > 0) - { - float num5 = MathHelper.Clamp((float)Math.Sin((double)((float)NPC.MoonLordCountdown / 60f * 0.5f)) * 2f, 0f, 1f); -@@ -51846,7 +51882,6 @@ - { - Filters.Scene.Deactivate("MoonLordShake", new object[0]); - } --#endif - if (NPC.MoonLordCountdown > 0) - { - NPC.MoonLordCountdown--; diff --git a/Patcher/patches/tModLoader/Terraria/NPC.cs.patch b/patches/tModLoader/Terraria/NPC.cs.patch similarity index 53% rename from Patcher/patches/tModLoader/Terraria/NPC.cs.patch rename to patches/tModLoader/Terraria/NPC.cs.patch index 51a312bf8be..4bdd6331a55 100644 --- a/Patcher/patches/tModLoader/Terraria/NPC.cs.patch +++ b/patches/tModLoader/Terraria/NPC.cs.patch @@ -71,138 +71,7 @@ { if (Main.netMode != 1) { -@@ -38635,7 +38644,6 @@ - 31, - 229 - }); --#if CLIENT - if (flag159) - { - MoonlordDeathDrama.AddExplosion(vector201); -@@ -38649,7 +38657,6 @@ - dust14.scale = num1628; - } - } --#endif - for (float num1631 = 0f; num1631 < this.ai[1] / 60f; num1631 += 1f) - { - Vector2 vector202 = Utils.RandomVector2(Main.rand, -1f, 1f); -@@ -45169,15 +45176,18 @@ - case 2: - case 4: - case 5: -- break; -+ goto IL_97D; -+ case 3: - default: - if (num8 != 0) - { - this.frame.Y = 0; - this.frameCounter = 0.0; -- } -- break; -- } -+ goto IL_97D; -+ } -+ goto IL_97D; -+ } -+ IL_97D: - int num9; - if (this.frameCounter < 10.0) - { -@@ -45309,15 +45319,18 @@ - case 2: - case 4: - case 5: -- break; -+ goto IL_DC7; -+ case 3: - default: - if (num12 != 0) - { - this.frame.Y = 0; - this.frameCounter = 0.0; -- } -- break; -- } -+ goto IL_DC7; -+ } -+ goto IL_DC7; -+ } -+ IL_DC7: - int num13 = 0; - if (this.frameCounter < 16.0) - { -@@ -45363,15 +45376,18 @@ - case 2: - case 4: - case 5: -- break; -+ goto IL_F6F; -+ case 3: - default: - if (num14 != 0) - { - this.frame.Y = 0; - this.frameCounter = 0.0; -- } -- break; -- } -+ goto IL_F6F; -+ } -+ goto IL_F6F; -+ } -+ IL_F6F: - int num15; - if (this.frameCounter < 10.0) - { -@@ -45540,15 +45556,18 @@ - case 2: - case 4: - case 5: -- break; -+ goto IL_1396; -+ case 3: - default: - if (num28 != 0) - { - this.frame.Y = 0; - this.frameCounter = 0.0; -- } -- break; -- } -+ goto IL_1396; -+ } -+ goto IL_1396; -+ } -+ IL_1396: - bool flag = this.ai[0] == 3f; - int num29 = 0; - int num30 = 0; -@@ -45661,15 +45680,18 @@ - case 2: - case 4: - case 5: -- break; -+ goto IL_16FF; -+ case 3: - default: - if (num33 != 0) - { - this.frame.Y = 0; - this.frameCounter = 0.0; -- } -- break; -- } -+ goto IL_16FF; -+ } -+ goto IL_16FF; -+ } -+ IL_16FF: - bool flag2 = this.ai[0] == 16f; - int num34 = 0; - int num35 = -1; -@@ -53801,7 +53823,7 @@ +@@ -53816,7 +53825,7 @@ public void NPCLoot() { @@ -211,7 +80,7 @@ { return; } -@@ -53916,6 +53938,10 @@ +@@ -53931,6 +53940,10 @@ } } if (this.type == 23 && Main.hardMode) @@ -222,7 +91,7 @@ { return; } -@@ -57120,6 +57146,7 @@ +@@ -57135,6 +57148,7 @@ NetMessage.SendData(25, -1, -1, Lang.misc[32], 255, 50f, 255f, 130f, 0, 0, 0); } } diff --git a/patches/tModLoader/Terraria/NetMessage.cs.patch b/patches/tModLoader/Terraria/NetMessage.cs.patch new file mode 100644 index 00000000000..dbc9f9b3ea9 --- /dev/null +++ b/patches/tModLoader/Terraria/NetMessage.cs.patch @@ -0,0 +1,12 @@ +--- src/Terraria\Terraria\NetMessage.cs ++++ src/tModLoader\Terraria\NetMessage.cs +@@ -1557,7 +1557,7 @@ + if (tile2.wall != 0) + { + b |= 4; +- array4[num5] = tile2.wall; ++ array4[num5] = (byte)tile2.wall; + num5++; + if (tile2.wallColor() != 0) + { + diff --git a/Patcher/patches/tModLoader/Terraria/Player.cs.patch b/patches/tModLoader/Terraria/Player.cs.patch similarity index 74% rename from Patcher/patches/tModLoader/Terraria/Player.cs.patch rename to patches/tModLoader/Terraria/Player.cs.patch index fd6e5fa6452..c151ae0e6a5 100644 --- a/Patcher/patches/tModLoader/Terraria/Player.cs.patch +++ b/patches/tModLoader/Terraria/Player.cs.patch @@ -1,14 +1,24 @@ --- src/Terraria\Terraria\Player.cs +++ src/tModLoader\Terraria\Player.cs -@@ -14,6 +14,7 @@ +@@ -14,6 +14,8 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.IO; +using Terraria.ModLoader; ++using Terraria.ModLoader.IO; using Terraria.ObjectData; using Terraria.Social; using Terraria.UI; -@@ -581,8 +582,8 @@ +@@ -63,7 +65,7 @@ + public const int defaultWidth = 20; + public const int defaultHeight = 42; + private const int shadowMax = 3; +- private static byte[] ENCRYPTION_KEY = new UnicodeEncoding().GetBytes("h3y_gUyZ"); ++ internal static byte[] ENCRYPTION_KEY = new UnicodeEncoding().GetBytes("h3y_gUyZ"); + public Player.OverheadMessage chatOverhead = default(Player.OverheadMessage); + public bool alchemyTable; + private bool GoingDownWithGrapple; +@@ -581,8 +583,8 @@ public bool oldAdjWater; public bool oldAdjHoney; public bool oldAdjLava; @@ -19,7 +29,7 @@ private static int defaultItemGrabRange = 38; private static float itemGrabSpeed = 0.45f; private static float itemGrabSpeedMax = 4f; -@@ -720,8 +721,8 @@ +@@ -720,8 +722,8 @@ public int cPet; public int cLight; public int cYorai; @@ -30,7 +40,7 @@ public int lastPortalColorIndex; public int _portalPhysicsTime; public bool portalPhysicsFlag; -@@ -2423,6 +2424,11 @@ +@@ -2423,6 +2425,11 @@ public void openPresent() { @@ -42,7 +52,7 @@ if (Main.rand.Next(15) == 0 && Main.hardMode) { int number = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, 602, 1, false, 0, false, false); -@@ -2698,6 +2704,11 @@ +@@ -2698,6 +2705,11 @@ public void OpenBossBag(int type) { @@ -54,7 +64,7 @@ if (type == 3318) { if (Main.rand.Next(2) == 0) -@@ -3287,6 +3298,11 @@ +@@ -3287,6 +3299,11 @@ public void openCrate(int type) { @@ -66,7 +76,7 @@ int num = type - 2334; if (type >= 3203) { -@@ -4320,6 +4336,11 @@ +@@ -4320,6 +4337,11 @@ public void openLockBox() { @@ -78,7 +88,7 @@ bool flag = true; while (flag) { -@@ -4454,6 +4475,11 @@ +@@ -4454,6 +4476,11 @@ public void openHerbBag() { @@ -90,7 +100,7 @@ int num = Main.rand.Next(2, 5); if (Main.rand.Next(3) == 0) { -@@ -4533,6 +4559,11 @@ +@@ -4533,6 +4560,11 @@ public void openGoodieBag() { @@ -102,7 +112,7 @@ if (Main.rand.Next(150) == 0) { int number = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, 1810, 1, false, 0, false, false); -@@ -6818,6 +6849,7 @@ +@@ -6818,6 +6850,7 @@ { this.accDreamCatcher = true; } @@ -110,7 +120,7 @@ } for (int k = 0; k < 8 + this.extraAccessorySlots; k++) { -@@ -7644,6 +7676,7 @@ +@@ -7644,6 +7677,7 @@ { this.meleeSpeed += 0.04f; } @@ -118,7 +128,7 @@ } } bool flag = false; -@@ -8783,6 +8816,7 @@ +@@ -8783,6 +8817,7 @@ Main.musicBox2 = 37; } } @@ -126,7 +136,7 @@ } } for (int m = 3; m < 8 + this.extraAccessorySlots; m++) -@@ -9390,6 +9424,7 @@ +@@ -9390,6 +9425,7 @@ { this.DelBuff(this.HasBuff(187)); } @@ -134,7 +144,7 @@ } public void UpdateSocialShadow() -@@ -14417,6 +14452,7 @@ +@@ -14417,6 +14453,7 @@ num3 = 1.5f; num = 0.125f; } @@ -142,7 +152,7 @@ this.velocity.Y = this.velocity.Y - num * this.gravDir; if (this.gravDir == 1f) { -@@ -18139,6 +18175,7 @@ +@@ -18139,6 +18176,7 @@ { this.accRunSpeed = 7f; } @@ -150,7 +160,7 @@ } if (this.sticky) { -@@ -20501,6 +20538,7 @@ +@@ -20501,6 +20539,7 @@ this.showItemIcon = true; this.showItemIcon2 = (int)(583 + Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18); } @@ -158,7 +168,7 @@ if (this.controlUseTile) { if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 212 && this.launcherWait <= 0) -@@ -20934,11 +20972,11 @@ +@@ -20934,11 +20973,11 @@ } } } @@ -172,7 +182,7 @@ { int num209 = 1141; for (int num210 = 0; num210 < 58; num210++) -@@ -20964,7 +21002,7 @@ +@@ -20964,7 +21003,7 @@ NetMessage.SendData(19, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.direction, 0, 0, 0); } } @@ -181,7 +191,7 @@ { NetMessage.SendData(19, -1, -1, "", 1, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.direction, 0, 0, 0); } -@@ -21238,6 +21276,7 @@ +@@ -21238,6 +21277,7 @@ Projectile.NewProjectile(vector4.X, vector4.Y, 0f, 0f, 403, 0, 0f, this.whoAmI, 0f, 0f); } } @@ -189,7 +199,7 @@ } this.releaseUseTile = false; } -@@ -22357,10 +22396,16 @@ +@@ -22357,10 +22397,16 @@ { num += 100; } @@ -206,7 +216,7 @@ if (ItemID.Sets.NebulaPickup[Main.item[j].type]) { Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1); -@@ -22425,7 +22470,10 @@ +@@ -22425,7 +22471,10 @@ else if (new Rectangle((int)this.position.X - num, (int)this.position.Y - num, this.width + num * 2, this.height + num * 2).Intersects(new Rectangle((int)Main.item[j].position.X, (int)Main.item[j].position.Y, Main.item[j].width, Main.item[j].height)) && this.ItemSpace(Main.item[j])) { Main.item[j].beingGrabbed = true; @@ -218,16 +228,16 @@ { float num3 = 12f; Vector2 vector = new Vector2(Main.item[j].position.X + (float)(Main.item[j].width / 2), Main.item[j].position.Y + (float)(Main.item[j].height / 2)); -@@ -23150,7 +23198,7 @@ +@@ -23150,7 +23199,7 @@ { int num = 4; int num2 = 3; - for (int i = 0; i < 419; i++) -+ for (int i = 0; i < adjTile.Length; i++) ++ for (int i = 0; i < this.adjTile.Length; i++) { this.oldAdjTile[i] = this.adjTile[i]; this.adjTile[i] = false; -@@ -23198,6 +23246,7 @@ +@@ -23198,6 +23247,7 @@ this.adjTile[14] = true; this.alchemyTable = true; } @@ -235,7 +245,7 @@ } if (Main.tile[j, k].liquid > 200 && Main.tile[j, k].liquidType() == 0) { -@@ -23843,6 +23892,10 @@ +@@ -23843,6 +23893,10 @@ } } } @@ -246,7 +256,7 @@ } } else -@@ -23878,6 +23931,10 @@ +@@ -23878,6 +23932,10 @@ if (this.inventory[this.selectedItem].holdStyle == 3) { this.bodyFrame.Y = this.bodyFrame.Height * 3; @@ -257,7 +267,7 @@ return; } if (this.grappling[0] >= 0) -@@ -25596,7 +25653,10 @@ +@@ -25596,7 +25654,10 @@ bool flag3 = false; bool flag4 = false; TileObject tileObject = default(TileObject); @@ -269,7 +279,7 @@ { flag4 = true; flag3 = TileObject.CanPlace(Player.tileTargetX, Player.tileTargetY, (int)((ushort)this.inventory[this.selectedItem].createTile), this.inventory[this.selectedItem].placeStyle, this.direction, out tileObject, false); -@@ -27320,7 +27380,7 @@ +@@ -27320,7 +27381,7 @@ { this.altFunctionUse = 2; } @@ -278,7 +288,7 @@ if (item.shoot == 0) { this.itemRotation = 0f; -@@ -28282,6 +28342,7 @@ +@@ -28282,6 +28343,7 @@ this.itemLocation.Y = this.MountedCenter.Y - (float)Main.itemTexture[item.type].Height * 0.5f; } } @@ -286,7 +296,7 @@ } } else if (item.holdStyle == 1 && !this.pulley) -@@ -28478,6 +28539,7 @@ +@@ -28478,6 +28540,7 @@ this.itemLocation.Y = this.MountedCenter.Y - (float)Main.itemTexture[item.type].Height * 0.5f; this.itemRotation = 0f; } @@ -294,7 +304,7 @@ if ((((item.type == 974 || item.type == 8 || item.type == 1245 || item.type == 2274 || item.type == 3004 || item.type == 3045 || item.type == 3114 || (item.type >= 427 && item.type <= 433)) && !this.wet) || item.type == 523 || item.type == 1333) && !this.pulley) { float num50 = 1f; -@@ -28923,6 +28985,7 @@ +@@ -28923,6 +28986,7 @@ Lighting.AddLight(position16, 1f, 0.6f, 0.85f); } } @@ -302,7 +312,7 @@ if (this.controlUseItem) { this.releaseUseItem = false; -@@ -30112,7 +30175,7 @@ +@@ -30112,7 +30176,7 @@ } Projectile.NewProjectile(vector2.X, vector2.Y - this.gravDir * 4f, num202, num203, num71, num73, num74, i, 0f, (float)Main.rand.Next(12) / 6f); } @@ -311,7 +321,7 @@ { int num204 = Projectile.NewProjectile(vector2.X, vector2.Y, num78, num79, num71, num73, num74, i, 0f, 0f); if (item.type == 726) -@@ -30481,7 +30544,7 @@ +@@ -30481,7 +30545,7 @@ flag14 = false; if (item.hammer > 0) { @@ -320,7 +330,7 @@ if (!WorldGen.CanKillTile(Player.tileTargetX, Player.tileTargetY)) { num222 = 0; -@@ -30525,7 +30588,7 @@ +@@ -30525,7 +30589,7 @@ } else { @@ -329,7 +339,7 @@ } if (item.axe > 0) { -@@ -30589,7 +30652,10 @@ +@@ -30589,7 +30653,10 @@ { int num223 = Player.tileTargetX; int num224 = Player.tileTargetY; @@ -341,7 +351,7 @@ { if (Main.tile[num223, num224].halfBrick()) { -@@ -31059,6 +31125,7 @@ +@@ -31059,6 +31126,7 @@ r2.Height = (int)((double)r2.Height * 0.6); } } @@ -349,7 +359,7 @@ float arg_BA93_0 = this.gravDir; if (item.type == 1450 && Main.rand.Next(3) == 0) { -@@ -31418,6 +31485,7 @@ +@@ -31418,6 +31486,7 @@ Dust expr_D7D2_cp_0 = Main.dust[num280]; expr_D7D2_cp_0.velocity.Y = expr_D7D2_cp_0.velocity.Y * 2f; } @@ -357,7 +367,7 @@ if (Main.myPlayer == i && (item.type == 1991 || item.type == 3183)) { for (int num281 = 0; num281 < 200; num281++) -@@ -31543,6 +31611,7 @@ +@@ -31543,6 +31612,7 @@ { flag18 = true; } @@ -365,7 +375,7 @@ int num293 = Item.NPCtoBanner(Main.npc[num292].BannerID()); if (num293 > 0 && this.NPCBannerBuff[num293]) { -@@ -31630,6 +31699,7 @@ +@@ -31630,6 +31700,7 @@ NetMessage.SendData(21, -1, -1, "", num300, 0f, 0f, 0f, 0, 0, 0); } } @@ -373,7 +383,7 @@ int num301 = Item.NPCtoBanner(Main.npc[num292].BannerID()); if (num301 >= 0) { -@@ -31681,6 +31751,7 @@ +@@ -31681,6 +31752,7 @@ { flag20 = true; } @@ -381,7 +391,7 @@ int num303 = Main.DamageVar((float)num282); this.StatusPvP(item.type, num302); this.OnHit(Main.player[num302].Center.X, Main.player[num302].Center.Y, Main.player[num302]); -@@ -31731,6 +31802,7 @@ +@@ -31731,6 +31803,7 @@ { this.pumpkinSword(num302, (int)((double)num282 * 1.5), num283); } @@ -389,7 +399,7 @@ if (Main.netMode != 0) { if (flag20) -@@ -31812,6 +31884,7 @@ +@@ -31812,6 +31885,7 @@ } if (this.itemTime == 0 && this.itemAnimation > 0) { @@ -397,7 +407,7 @@ if (item.hairDye >= 0) { this.itemTime = item.useTime; -@@ -32325,6 +32398,7 @@ +@@ -32325,6 +32399,7 @@ { flag22 = true; } @@ -405,7 +415,7 @@ if (flag22) { if (item.stack > 0) -@@ -32649,6 +32723,10 @@ +@@ -32649,6 +32724,10 @@ { flag2 = true; } @@ -416,7 +426,7 @@ if (!flag2 && item.consumable) { item.stack--; -@@ -32701,7 +32779,7 @@ +@@ -32701,7 +32780,7 @@ } else { @@ -425,7 +435,7 @@ } if (tile.type == 211 && pickPower < 200) { -@@ -32769,6 +32847,10 @@ +@@ -32769,6 +32848,10 @@ else if (tile.type == 223 && pickPower < 150) { num = 0; @@ -436,20 +446,7 @@ } if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397) { -@@ -32870,12 +32952,10 @@ - int num4 = y; - bool flag3 = Main.tile[x, num4].active(); - WorldGen.KillTile(x, num4, false, false, false); --#if CLIENT - if (flag3 && !Main.tile[x, num4].active()) - { - AchievementsHelper.HandleMining(); - } --#endif - if (Main.netMode == 1) - { - NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)num4, 0f, 0, 0, 0); -@@ -33377,7 +33457,7 @@ +@@ -33377,7 +33460,7 @@ { return false; } @@ -458,27 +455,27 @@ { return false; } -@@ -33586,12 +33666,12 @@ +@@ -33586,12 +33669,12 @@ { player.armor[k].name = ""; } - binaryWriter.Write(player.armor[k].netID); -+ ItemLoader.WriteID(player.armor[k], binaryWriter); ++ ItemIO.WriteVanillaID(player.armor[k], binaryWriter); binaryWriter.Write(player.armor[k].prefix); } for (int l = 0; l < player.dye.Length; l++) { - binaryWriter.Write(player.dye[l].netID); -+ ItemLoader.WriteID(player.dye[l], binaryWriter); ++ ItemIO.WriteVanillaID(player.dye[l], binaryWriter); binaryWriter.Write(player.dye[l].prefix); } for (int m = 0; m < 58; m++) -@@ -33600,16 +33680,16 @@ +@@ -33600,16 +33683,16 @@ { player.inventory[m].name = ""; } - binaryWriter.Write(player.inventory[m].netID); -+ ItemLoader.WriteID(player.inventory[m], binaryWriter); ++ ItemIO.WriteVanillaID(player.inventory[m], binaryWriter); binaryWriter.Write(player.inventory[m].stack); binaryWriter.Write(player.inventory[m].prefix); binaryWriter.Write(player.inventory[m].favorited); @@ -486,120 +483,53 @@ for (int n = 0; n < player.miscEquips.Length; n++) { - binaryWriter.Write(player.miscEquips[n].netID); -+ ItemLoader.WriteID(player.miscEquips[n], binaryWriter); ++ ItemIO.WriteVanillaID(player.miscEquips[n], binaryWriter); binaryWriter.Write(player.miscEquips[n].prefix); - binaryWriter.Write(player.miscDyes[n].netID); -+ ItemLoader.WriteID(player.miscDyes[n], binaryWriter); ++ ItemIO.WriteVanillaID(player.miscDyes[n], binaryWriter); binaryWriter.Write(player.miscDyes[n].prefix); } for (int num = 0; num < 40; num++) -@@ -33618,7 +33698,7 @@ +@@ -33618,7 +33701,7 @@ { player.bank.item[num].name = ""; } - binaryWriter.Write(player.bank.item[num].netID); -+ ItemLoader.WriteID(player.bank.item[num], binaryWriter); ++ ItemIO.WriteVanillaID(player.bank.item[num], binaryWriter); binaryWriter.Write(player.bank.item[num].stack); binaryWriter.Write(player.bank.item[num].prefix); } -@@ -33628,7 +33708,7 @@ +@@ -33628,7 +33711,7 @@ { player.bank2.item[num2].name = ""; } - binaryWriter.Write(player.bank2.item[num2].netID); -+ ItemLoader.WriteID(player.bank2.item[num2], binaryWriter); ++ ItemIO.WriteVanillaID(player.bank2.item[num2], binaryWriter); binaryWriter.Write(player.bank2.item[num2].stack); binaryWriter.Write(player.bank2.item[num2].prefix); } -@@ -33848,7 +33928,7 @@ - int num4 = 20; - for (int m = 0; m < num4; m++) - { -- player.armor[m].netDefaults(binaryReader.ReadInt32()); -+ ItemLoader.ReadID(player.armor[m], binaryReader); - player.armor[m].Prefix((int)binaryReader.ReadByte()); - } - } -@@ -33866,7 +33946,7 @@ - for (int n = 0; n < num5; n++) - { - int num6 = n; -- player.dye[num6].netDefaults(binaryReader.ReadInt32()); -+ ItemLoader.ReadID(player.dye[num6], binaryReader); - player.dye[num6].Prefix((int)binaryReader.ReadByte()); - } - } -@@ -33874,20 +33954,12 @@ - { - for (int num7 = 0; num7 < 58; num7++) - { -- int num8 = binaryReader.ReadInt32(); -- if (num8 >= 3602) -+ ItemLoader.ReadID(player.inventory[num7], binaryReader); -+ player.inventory[num7].stack = binaryReader.ReadInt32(); -+ player.inventory[num7].Prefix((int)binaryReader.ReadByte()); -+ if (num >= 114) - { -- player.inventory[num7].netDefaults(0); -- } -- else -- { -- player.inventory[num7].netDefaults(num8); -- player.inventory[num7].stack = binaryReader.ReadInt32(); -- player.inventory[num7].Prefix((int)binaryReader.ReadByte()); -- if (num >= 114) -- { -- player.inventory[num7].favorited = binaryReader.ReadBoolean(); -- } -+ player.inventory[num7].favorited = binaryReader.ReadBoolean(); - } - } - } -@@ -33943,26 +34015,10 @@ - { - for (int num13 = 0; num13 < 5; num13++) - { -- int num14 = binaryReader.ReadInt32(); -- if (num14 >= 3602) -- { -- player.miscEquips[num13].netDefaults(0); -- } -- else -- { -- player.miscEquips[num13].netDefaults(num14); -- player.miscEquips[num13].Prefix((int)binaryReader.ReadByte()); -- } -- num14 = binaryReader.ReadInt32(); -- if (num14 >= 3602) -- { -- player.miscDyes[num13].netDefaults(0); -- } -- else -- { -- player.miscDyes[num13].netDefaults(num14); -- player.miscDyes[num13].Prefix((int)binaryReader.ReadByte()); -- } -+ ItemLoader.ReadID(player.miscEquips[num13], binaryReader); -+ player.miscEquips[num13].Prefix((int)binaryReader.ReadByte()); -+ ItemLoader.ReadID(player.miscDyes[num13], binaryReader); -+ player.miscDyes[num13].Prefix((int)binaryReader.ReadByte()); - } - } - } -@@ -33970,13 +34026,13 @@ - { - for (int num15 = 0; num15 < 40; num15++) - { -- player.bank.item[num15].netDefaults(binaryReader.ReadInt32()); -+ ItemLoader.ReadID(player.bank.item[num15], binaryReader); - player.bank.item[num15].stack = binaryReader.ReadInt32(); - player.bank.item[num15].Prefix((int)binaryReader.ReadByte()); - } - for (int num16 = 0; num16 < 40; num16++) - { -- player.bank2.item[num16].netDefaults(binaryReader.ReadInt32()); -+ ItemLoader.ReadID(player.bank2.item[num16], binaryReader); - player.bank2.item[num16].stack = binaryReader.ReadInt32(); - player.bank2.item[num16].Prefix((int)binaryReader.ReadByte()); - } +@@ -33673,6 +33756,7 @@ + } + } + } ++ PlayerIO.WriteModFile(player, path, isCloudSave); + } + + public static PlayerFileData LoadPlayer(string playerPath, bool cloudSave) +@@ -34116,6 +34200,7 @@ + player.anglerQuestsFinished = binaryReader.ReadInt32(); + } + player.skinVariant = (int)MathHelper.Clamp((float)player.skinVariant, 0f, 7f); ++ PlayerIO.ReadModFile(player, playerPath, cloudSave); + for (int num32 = 3; num32 < 8 + player.extraAccessorySlots; num32++) + { + int type = player.armor[num32].type; +@@ -34184,6 +34269,7 @@ + if (FileUtilities.Exists(file + ".bak", cloudSave)) + { + FileUtilities.Move(file + ".bak", file, cloudSave, true); ++ PlayerIO.LoadBackup(file, cloudSave); + } + playerFileData = Player.LoadPlayer(file, cloudSave); + if (playerFileData.Player == null) diff --git a/patches/tModLoader/Terraria/Program.cs.patch b/patches/tModLoader/Terraria/Program.cs.patch new file mode 100644 index 00000000000..f81092107d3 --- /dev/null +++ b/patches/tModLoader/Terraria/Program.cs.patch @@ -0,0 +1,14 @@ +--- src/Terraria\Terraria\Program.cs ++++ src/tModLoader\Terraria\Program.cs +@@ -89,6 +89,10 @@ + public static void LaunchGame(string[] args) + { + Program.LaunchParameters = Utils.ParseArguements(args); ++ if (Program.LaunchParameters.ContainsKey("-savedirectory")) ++ { ++ Program.LaunchParameters["-savedirectory"] = Path.Combine(Program.LaunchParameters["-savedirectory"], "ModLoader"); ++ } + ThreadPool.SetMinThreads(8, 8); + using (Main main = new Main()) + { + diff --git a/Patcher/patches/tModLoader/Terraria/Projectile.cs.patch b/patches/tModLoader/Terraria/Projectile.cs.patch similarity index 70% rename from Patcher/patches/tModLoader/Terraria/Projectile.cs.patch rename to patches/tModLoader/Terraria/Projectile.cs.patch index cd8ba839349..57a5e72093c 100644 --- a/Patcher/patches/tModLoader/Terraria/Projectile.cs.patch +++ b/patches/tModLoader/Terraria/Projectile.cs.patch @@ -44,17 +44,8 @@ case "Random": return Main.rand.NextFloat(); + case "bluemagic123": -+ return 0.6f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.1f; ++ return 0.55f + (float)Math.Cos(Main.time / 120.0 * 6.2831854820251465) * 0.1f; } } return (float)((int)indexing) / 6f; -@@ -20638,7 +20645,7 @@ - int num688 = (int)(this.position.Y + (float)this.height) / 16 + 1; - if (WorldGen.SolidTile(num687, num688) || Main.tile[num687, num688].halfBrick()) - { -- goto Block_1933;//IL_1C179; -+ goto Block_1933;// IL_1C179; - } - if (Main.tile[num687, num688].slope() > 0) - { diff --git a/Patcher/patches/tModLoader/Terraria/Recipe.cs.patch b/patches/tModLoader/Terraria/Recipe.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria/Recipe.cs.patch rename to patches/tModLoader/Terraria/Recipe.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria/Tile.cs.patch b/patches/tModLoader/Terraria/Tile.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria/Tile.cs.patch rename to patches/tModLoader/Terraria/Tile.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria/TileObject.cs.patch b/patches/tModLoader/Terraria/TileObject.cs.patch similarity index 100% rename from Patcher/patches/tModLoader/Terraria/TileObject.cs.patch rename to patches/tModLoader/Terraria/TileObject.cs.patch diff --git a/Patcher/patches/tModLoader/Terraria/Wiring.cs.patch b/patches/tModLoader/Terraria/Wiring.cs.patch similarity index 95% rename from Patcher/patches/tModLoader/Terraria/Wiring.cs.patch rename to patches/tModLoader/Terraria/Wiring.cs.patch index f5ab5528d67..6f475e82ffe 100644 --- a/Patcher/patches/tModLoader/Terraria/Wiring.cs.patch +++ b/patches/tModLoader/Terraria/Wiring.cs.patch @@ -33,7 +33,7 @@ private static int[] _mechX; private static int[] _mechY; private static int _numMechs; -@@ -200,7 +201,7 @@ +@@ -204,7 +205,7 @@ } } @@ -42,7 +42,7 @@ { for (int k = 0; k < Wiring._numMechs; k++) { -@@ -274,7 +275,7 @@ +@@ -278,7 +279,7 @@ } } @@ -51,7 +51,7 @@ { if (Main.netMode == 1) { -@@ -652,7 +653,7 @@ +@@ -656,7 +657,7 @@ NetMessage.SendData(19, -1, -1, "", 4 + flag.ToInt(), (float)i, (float)j, 0f, 0, 0, 0); return; } @@ -60,7 +60,7 @@ { if (WorldGen.CloseDoor(i, j, true)) { -@@ -660,7 +661,7 @@ +@@ -664,7 +665,7 @@ return; } } @@ -69,7 +69,7 @@ { int num26 = 1; if (Main.rand.Next(2) == 0) -@@ -1450,6 +1451,7 @@ +@@ -1454,6 +1455,7 @@ } } } diff --git a/Patcher/patches/tModLoader/Terraria/WorldGen.cs.patch b/patches/tModLoader/Terraria/WorldGen.cs.patch similarity index 81% rename from Patcher/patches/tModLoader/Terraria/WorldGen.cs.patch rename to patches/tModLoader/Terraria/WorldGen.cs.patch index 6bf34403aad..3412043d2ec 100644 --- a/Patcher/patches/tModLoader/Terraria/WorldGen.cs.patch +++ b/patches/tModLoader/Terraria/WorldGen.cs.patch @@ -1,18 +1,16 @@ --- src/Terraria\Terraria\WorldGen.cs +++ src/tModLoader\Terraria\WorldGen.cs -@@ -13,16 +13,15 @@ +@@ -13,6 +13,8 @@ using Terraria.Graphics.Capture; using Terraria.ID; using Terraria.IO; -+using Terraria.Map; +using Terraria.ModLoader; ++using Terraria.ModLoader.IO; using Terraria.ObjectData; using Terraria.Utilities; using Terraria.World.Generation; - --#if CLIENT --using Terraria.Map; --#endif +@@ -22,7 +24,7 @@ + #endif namespace Terraria { - internal class WorldGen @@ -20,7 +18,7 @@ { public class Spread { -@@ -1587,7 +1586,7 @@ +@@ -1587,7 +1589,7 @@ } } } @@ -29,7 +27,7 @@ { if (num8 > 0) { -@@ -1644,7 +1643,7 @@ +@@ -1644,7 +1646,7 @@ WorldGen.roomY1 = y; WorldGen.roomY2 = y; WorldGen.numRoomTiles = 0; @@ -38,7 +36,7 @@ { WorldGen.houseTile[i] = false; } -@@ -1891,7 +1890,7 @@ +@@ -1891,7 +1893,7 @@ { for (int n = j - num; n < j + num; n++) { @@ -47,7 +45,7 @@ { return false; } -@@ -2037,6 +2036,18 @@ +@@ -2037,6 +2039,18 @@ public static void worldGenCallBack(object threadContext) { @@ -66,11 +64,10 @@ Main.PlaySound(10, -1, -1, 1); WorldGen.clearWorld(); WorldGen.generateWorld(-1, threadContext as GenerationProgress); -@@ -2101,6 +2112,18 @@ - } +@@ -2102,6 +2116,18 @@ public static void playWorldCallBack(object threadContext) -+ { + { + try + { + do_playWorldCallBack(threadContext); @@ -82,54 +79,27 @@ + } + + public static void do_playWorldCallBack(object threadContext) - { ++ { if (Main.rand == null) { -@@ -8774,17 +8797,18 @@ - { - int num5; - int num6; -+ bool flag2; - int maxValue; -- bool flag2; - switch (k) + Main.rand = new Random((int)DateTime.Now.Ticks); +@@ -2149,6 +2175,7 @@ + FileUtilities.Copy(Main.worldPathName, Main.worldPathName + ".bad", isCloudSave, true); + FileUtilities.Copy(Main.worldPathName + ".bak", Main.worldPathName, isCloudSave, true); + FileUtilities.Delete(Main.worldPathName + ".bak", isCloudSave); ++ WorldIO.LoadDedServBackup(Main.worldPathName, isCloudSave); + WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave); + if (WorldGen.loadFailed || !WorldGen.loadSuccess) { -+ case 0: - default: - { - num5 = 5; - num6 = num4; - flag2 = false; - maxValue = num3; -- break; -+ goto IL_77; - } - case 1: - { -@@ -8792,7 +8816,7 @@ - num6 = Main.maxTilesX - num2; - flag2 = true; - maxValue = num; -- break; -+ goto IL_77; - } - case 2: - { -@@ -8800,9 +8824,10 @@ - num6 = Main.maxTilesX - 5; - flag2 = false; - maxValue = num3; -- break; -- } -- } -+ goto IL_77; -+ } -+ } -+ IL_77: - for (int l = num5; l < num6; l++) - { - if (WorldGen.genRand.Next(maxValue) == 0) -@@ -12811,7 +12836,7 @@ +@@ -2158,6 +2185,7 @@ + FileUtilities.Copy(Main.worldPathName, Main.worldPathName + ".bak", isCloudSave, true); + FileUtilities.Copy(Main.worldPathName + ".bad", Main.worldPathName, isCloudSave, true); + FileUtilities.Delete(Main.worldPathName + ".bad", isCloudSave); ++ WorldIO.RevertDedServBackup(Main.worldPathName, isCloudSave); + Console.WriteLine("Load failed!"); + return; + } +@@ -12813,7 +12841,7 @@ Main.tile[i, j] = new Tile(); } int frameX = (int)Main.tile[i, j].frameX; @@ -138,7 +108,7 @@ { return false; } -@@ -12858,6 +12883,7 @@ +@@ -12860,6 +12888,7 @@ } } } @@ -146,7 +116,7 @@ for (int m = num5; m < num5 + 2; m++) { for (int n = num4; n < num4 + 3; n++) -@@ -12868,7 +12894,7 @@ +@@ -12870,7 +12899,7 @@ { Main.tile[m, n] = new Tile(); } @@ -155,40 +125,7 @@ Main.tile[m, n].frameX = (short)(WorldGen.genRand.Next(3) * 18); } else -@@ -13480,25 +13506,27 @@ - int num38; - switch (num36) - { -+ case 0: - default: - { - num37 = 1; - num38 = 3; -- break; -+ goto IL_FAB; - } - case 1: - { - num37 = 3; - num38 = 3; -- break; -+ goto IL_FAB; - } - case 2: - { - num37 = 1; - num38 = 2; -- break; -- } -- } -+ goto IL_FAB; -+ } -+ } -+ IL_FAB: - for (int num39 = num34 - 1; num39 <= num34 + num37; num39++) - { - for (int num40 = num35; num40 <= num35 + num38; num40++) -@@ -19549,11 +19577,7 @@ +@@ -19553,11 +19582,7 @@ { Main.tile[i, j] = new Tile(); } @@ -201,7 +138,7 @@ { return false; } -@@ -19616,8 +19640,9 @@ +@@ -19620,8 +19645,9 @@ } int num6 = num * 54; Main.PlaySound(8, i * 16, j * 16, 1); @@ -212,7 +149,7 @@ Main.tile[num4, num2].frameY = (short)num6; Main.tile[num4, num2].frameX = num3; Main.tile[num4, num2].color(color); -@@ -19626,7 +19651,7 @@ +@@ -19630,7 +19656,7 @@ Main.tile[num4 + 1, num2] = new Tile(); } Main.tile[num4 + 1, num2].active(true); @@ -221,7 +158,7 @@ Main.tile[num4 + 1, num2].frameY = (short)num6; Main.tile[num4 + 1, num2].frameX = (short)(num3 + 18); Main.tile[num4 + 1, num2].color(color); -@@ -19635,7 +19660,7 @@ +@@ -19639,7 +19665,7 @@ Main.tile[num4, num2 + 1] = new Tile(); } Main.tile[num4, num2 + 1].active(true); @@ -230,7 +167,7 @@ Main.tile[num4, num2 + 1].frameY = (short)(num6 + 18); Main.tile[num4, num2 + 1].frameX = num3; Main.tile[num4, num2 + 1].color(color2); -@@ -19644,7 +19669,7 @@ +@@ -19648,7 +19674,7 @@ Main.tile[num4 + 1, num2 + 1] = new Tile(); } Main.tile[num4 + 1, num2 + 1].active(true); @@ -239,7 +176,7 @@ Main.tile[num4 + 1, num2 + 1].frameY = (short)(num6 + 18); Main.tile[num4 + 1, num2 + 1].frameX = (short)(num3 + 18); Main.tile[num4 + 1, num2 + 1].color(color2); -@@ -19653,7 +19678,7 @@ +@@ -19657,7 +19683,7 @@ Main.tile[num4, num2 + 2] = new Tile(); } Main.tile[num4, num2 + 2].active(true); @@ -248,7 +185,7 @@ Main.tile[num4, num2 + 2].frameY = (short)(num6 + 36); Main.tile[num4, num2 + 2].frameX = num3; Main.tile[num4, num2 + 2].color(color3); -@@ -19662,7 +19687,7 @@ +@@ -19666,7 +19692,7 @@ Main.tile[num4 + 1, num2 + 2] = new Tile(); } Main.tile[num4 + 1, num2 + 2].active(true); @@ -257,7 +194,7 @@ Main.tile[num4 + 1, num2 + 2].frameY = (short)(num6 + 36); Main.tile[num4 + 1, num2 + 2].frameX = (short)(num3 + 18); Main.tile[num4 + 1, num2 + 2].color(color3); -@@ -25245,7 +25270,7 @@ +@@ -25249,7 +25275,7 @@ { } k = j - k / 18; @@ -266,7 +203,7 @@ } public static void OreRunner(int i, int j, double strength, int steps, ushort type) -@@ -25504,7 +25529,7 @@ +@@ -25508,7 +25534,7 @@ { flag = true; } @@ -275,7 +212,7 @@ { return; } -@@ -27223,10 +27248,6 @@ +@@ -27227,10 +27253,6 @@ public static bool PlaceObject(int x, int y, int type, bool mute = false, int style = 0, int alternate = 0, int random = -1, int direction = -1) { @@ -286,34 +223,34 @@ TileObject toBePlaced; if (!TileObject.CanPlace(x, y, type, style, direction, out toBePlaced, false)) { -@@ -29916,7 +29937,7 @@ +@@ -29920,7 +29942,7 @@ int wall = (int)Main.tile[k, l].wall; if (conversionType == 4) { - if (type <= 419 && wall <= 225) -+ if (wall <= 225) ++ if (true) { if (WallID.Sets.Conversion.Grass[wall] && wall != 81) { -@@ -29994,7 +30015,7 @@ +@@ -29998,7 +30020,7 @@ } else if (conversionType == 2) { - if (type <= 419 && wall <= 225) -+ if (wall <= 225) ++ if (true) { if (WallID.Sets.Conversion.Grass[wall] && wall != 70) { -@@ -30074,7 +30095,7 @@ +@@ -30078,7 +30100,7 @@ } else if (conversionType == 1) { - if (type <= 419 && wall <= 225) -+ if (wall <= 225) ++ if (true) { if (WallID.Sets.Conversion.Grass[wall] && wall != 69) { -@@ -31668,10 +31689,6 @@ +@@ -31672,10 +31694,6 @@ public static bool PlaceTile(int i, int j, int type, bool mute = false, bool forced = false, int plr = -1, int style = 0) { @@ -324,7 +261,7 @@ bool result = false; if (i >= 0 && j >= 0 && i < Main.maxTilesX && j < Main.maxTilesY) { -@@ -32309,7 +32326,11 @@ +@@ -32313,7 +32331,11 @@ { fail = true; } @@ -337,7 +274,7 @@ { Main.PlaySound(13, i * 16, j * 16, 1); } -@@ -32326,6 +32347,7 @@ +@@ -32330,6 +32352,7 @@ { num = 3; } @@ -345,7 +282,7 @@ for (int k = 0; k < num; k++) { int num2 = 0; -@@ -32793,6 +32815,10 @@ +@@ -32797,6 +32820,10 @@ if (tile.wall == 151 || tile.wall == 152) { num2 = 215; @@ -356,7 +293,7 @@ } if (tile.wall == 44) { -@@ -33293,14 +33319,14 @@ +@@ -33297,14 +33324,14 @@ { num4 = 2210 + (int)tile.wall - 138; } @@ -373,7 +310,7 @@ { WorldGen.TileFrame(i, j, false, false); } -@@ -33371,6 +33397,10 @@ +@@ -33375,6 +33402,10 @@ { return false; } @@ -384,7 +321,7 @@ if (j >= 1) { tile2 = Main.tile[i, j - 1]; -@@ -33443,7 +33473,7 @@ +@@ -33447,7 +33478,7 @@ int num2 = i - (int)(tile.frameX % 54 / 18); for (int k = 0; k < 3; k++) { @@ -393,7 +330,7 @@ { blockDamaged = true; return false; -@@ -33480,7 +33510,7 @@ +@@ -33484,7 +33515,7 @@ { Main.tile[i, j - 1] = new Tile(); } @@ -402,7 +339,7 @@ { if (Main.tile[i, j - 1].type == 5) { -@@ -33508,16 +33538,20 @@ +@@ -33512,16 +33543,20 @@ int num = i - frameX % 54 / 18; for (int k = 0; k < 3; k++) { @@ -425,7 +362,7 @@ { Main.PlaySound(2, i * 16, j * 16, 27); } -@@ -33760,6 +33794,7 @@ +@@ -33764,6 +33799,7 @@ { num13 = 0; } @@ -433,7 +370,7 @@ int num14 = 0; while (num14 < num13) { -@@ -35593,7 +35628,7 @@ +@@ -35597,7 +35633,7 @@ { num15 = 215; } @@ -442,7 +379,7 @@ { if (tile.type == 352 && num15 == 5) { -@@ -35783,6 +35818,7 @@ +@@ -35787,6 +35823,7 @@ { num45 = 10; } @@ -450,7 +387,7 @@ if (num43 > 0 && NPC.CountNPCS(357) < 5 && WorldGen.genRand.Next(num43) == 0) { int type2 = 357; -@@ -37390,7 +37426,8 @@ +@@ -37394,7 +37431,8 @@ { num49 = 2504; } @@ -460,7 +397,7 @@ { int num71 = 1; if (flag) -@@ -37399,7 +37436,7 @@ +@@ -37403,7 +37441,7 @@ } Item.NewItem(i * 16, j * 16, 16, 16, num49, num71, false, -1, false, false); } @@ -469,7 +406,7 @@ { Item.NewItem(i * 16, j * 16, 16, 16, num50, 1, false, -1, false, false); } -@@ -40012,6 +40049,8 @@ +@@ -40016,6 +40054,8 @@ } } } @@ -478,7 +415,7 @@ } num6++; } -@@ -40702,6 +40741,8 @@ +@@ -40706,6 +40746,8 @@ } } WorldGen.SpreadDesertWalls(num, num64, num65); @@ -487,23 +424,7 @@ } num63++; } -@@ -44909,7 +44950,6 @@ - public static bool UpdateMapTile(int i, int j, bool addToList = true) - { - bool result = false; --#if CLIENT - if (Main.mapEnabled && !WorldGen.noMapUpdate && !WorldGen.gen && Main.Map[i, j].Light > 0 && Main.Map.UpdateType(i, j) && addToList) - { - result = true; -@@ -44924,7 +44964,6 @@ - Main.refreshMap = true; - } - } --#endif - return result; - } - -@@ -45217,6 +45256,10 @@ +@@ -45221,6 +45263,10 @@ } if (tile.active()) { @@ -514,7 +435,7 @@ if (noBreak && Main.tileFrameImportant[(int)tile.type] && tile.type != 4) { return; -@@ -46278,6 +46321,10 @@ +@@ -46282,6 +46328,10 @@ { WorldGen.CheckPalmTree(i, j); } @@ -525,7 +446,7 @@ return; } else -@@ -49469,7 +49516,7 @@ +@@ -49473,7 +49523,7 @@ if (tile3 != null && !tile3.active()) { bool flag5 = true; @@ -534,7 +455,7 @@ { flag5 = false; } -@@ -49535,7 +49582,7 @@ +@@ -49539,7 +49589,7 @@ else if (Main.netMode == 2 && tile3 != null && !tile3.active()) { bool flag6 = true; diff --git a/Patcher/patches/tModLoader/TerrariaServer.csproj.patch b/patches/tModLoader/TerrariaServer.csproj.patch similarity index 75% rename from Patcher/patches/tModLoader/TerrariaServer.csproj.patch rename to patches/tModLoader/TerrariaServer.csproj.patch index a1e83fb8cf1..274d02d58ab 100644 --- a/Patcher/patches/tModLoader/TerrariaServer.csproj.patch +++ b/patches/tModLoader/TerrariaServer.csproj.patch @@ -1,18 +1,13 @@ --- src/Terraria\TerrariaServer.csproj +++ src/tModLoader\TerrariaServer.csproj -@@ -1,7 +1,7 @@ - - - -- {85BF1171-A0DC-4696-BFA4-D6E9DC4E0830} -+ {BE8168B8-377A-4216-8252-7A302F07C8BA} - Debug - x86 - Exe -@@ -243,6 +243,43 @@ +@@ -242,6 +242,47 @@ ++ ++ ++ ++ + + + @@ -53,12 +48,4 @@ -@@ -350,6 +387,7 @@ - - - -+ - - - diff --git a/Patcher/setup.bat b/setup.bat similarity index 100% rename from Patcher/setup.bat rename to setup.bat diff --git a/Patcher/setup/Properties/AssemblyInfo.cs b/setup/Properties/AssemblyInfo.cs similarity index 100% rename from Patcher/setup/Properties/AssemblyInfo.cs rename to setup/Properties/AssemblyInfo.cs diff --git a/Patcher/setup/Properties/Resources.Designer.cs b/setup/Properties/Resources.Designer.cs similarity index 100% rename from Patcher/setup/Properties/Resources.Designer.cs rename to setup/Properties/Resources.Designer.cs diff --git a/Patcher/setup/Properties/Resources.resx b/setup/Properties/Resources.resx similarity index 100% rename from Patcher/setup/Properties/Resources.resx rename to setup/Properties/Resources.resx diff --git a/Patcher/setup/Properties/Settings.Designer.cs b/setup/Properties/Settings.Designer.cs similarity index 100% rename from Patcher/setup/Properties/Settings.Designer.cs rename to setup/Properties/Settings.Designer.cs diff --git a/Patcher/setup/Properties/Settings.settings b/setup/Properties/Settings.settings similarity index 100% rename from Patcher/setup/Properties/Settings.settings rename to setup/Properties/Settings.settings diff --git a/Patcher/setup/Settings.cs b/setup/Settings.cs similarity index 100% rename from Patcher/setup/Settings.cs rename to setup/Settings.cs diff --git a/Patcher/setup/Setup/DecompileTask.cs b/setup/Setup/DecompileTask.cs similarity index 100% rename from Patcher/setup/Setup/DecompileTask.cs rename to setup/Setup/DecompileTask.cs diff --git a/Patcher/setup/Setup/DiffTask.cs b/setup/Setup/DiffTask.cs similarity index 97% rename from Patcher/setup/Setup/DiffTask.cs rename to setup/Setup/DiffTask.cs index 4b125fe8053..165eabc4256 100644 --- a/Patcher/setup/Setup/DiffTask.cs +++ b/setup/Setup/DiffTask.cs @@ -9,7 +9,7 @@ namespace Terraria.ModLoader.Setup { public class DiffTask : Task { - public static string[] extensions = {".cs", ".csproj", ".ico"}; + public static string[] extensions = {".cs", ".csproj"}; public static string[] excluded = {"bin" + Path.DirectorySeparatorChar, "obj" + Path.DirectorySeparatorChar}; public readonly string baseDir; diff --git a/Patcher/setup/Setup/FileFolderDialog.cs b/setup/Setup/FileFolderDialog.cs similarity index 100% rename from Patcher/setup/Setup/FileFolderDialog.cs rename to setup/Setup/FileFolderDialog.cs diff --git a/Patcher/setup/Setup/FormatTask.cs b/setup/Setup/FormatTask.cs similarity index 100% rename from Patcher/setup/Setup/FormatTask.cs rename to setup/Setup/FormatTask.cs diff --git a/Patcher/setup/Setup/ITaskInterface.cs b/setup/Setup/ITaskInterface.cs similarity index 100% rename from Patcher/setup/Setup/ITaskInterface.cs rename to setup/Setup/ITaskInterface.cs diff --git a/Patcher/setup/Setup/MainForm.Designer.cs b/setup/Setup/MainForm.Designer.cs similarity index 100% rename from Patcher/setup/Setup/MainForm.Designer.cs rename to setup/Setup/MainForm.Designer.cs diff --git a/Patcher/setup/Setup/MainForm.cs b/setup/Setup/MainForm.cs similarity index 100% rename from Patcher/setup/Setup/MainForm.cs rename to setup/Setup/MainForm.cs diff --git a/Patcher/setup/Setup/MainForm.resx b/setup/Setup/MainForm.resx similarity index 100% rename from Patcher/setup/Setup/MainForm.resx rename to setup/Setup/MainForm.resx diff --git a/Patcher/setup/Setup/PatchTask.cs b/setup/Setup/PatchTask.cs similarity index 100% rename from Patcher/setup/Setup/PatchTask.cs rename to setup/Setup/PatchTask.cs diff --git a/Patcher/setup/Setup/Program.cs b/setup/Setup/Program.cs similarity index 100% rename from Patcher/setup/Setup/Program.cs rename to setup/Setup/Program.cs diff --git a/Patcher/setup/Setup/ProgramSetting.cs b/setup/Setup/ProgramSetting.cs similarity index 100% rename from Patcher/setup/Setup/ProgramSetting.cs rename to setup/Setup/ProgramSetting.cs diff --git a/Patcher/setup/Setup/SelectFilesForm.Designer.cs b/setup/Setup/SelectFilesForm.Designer.cs similarity index 100% rename from Patcher/setup/Setup/SelectFilesForm.Designer.cs rename to setup/Setup/SelectFilesForm.Designer.cs diff --git a/Patcher/setup/Setup/SelectFilesForm.cs b/setup/Setup/SelectFilesForm.cs similarity index 100% rename from Patcher/setup/Setup/SelectFilesForm.cs rename to setup/Setup/SelectFilesForm.cs diff --git a/Patcher/setup/Setup/SelectFilesForm.resx b/setup/Setup/SelectFilesForm.resx similarity index 100% rename from Patcher/setup/Setup/SelectFilesForm.resx rename to setup/Setup/SelectFilesForm.resx diff --git a/Patcher/setup/Setup/SetupTask.cs b/setup/Setup/SetupTask.cs similarity index 100% rename from Patcher/setup/Setup/SetupTask.cs rename to setup/Setup/SetupTask.cs diff --git a/Patcher/setup/Setup/Task.cs b/setup/Setup/Task.cs similarity index 100% rename from Patcher/setup/Setup/Task.cs rename to setup/Setup/Task.cs diff --git a/Patcher/setup/app.config b/setup/app.config similarity index 100% rename from Patcher/setup/app.config rename to setup/app.config diff --git a/Patcher/setup/bin/setup.exe b/setup/bin/setup.exe similarity index 91% rename from Patcher/setup/bin/setup.exe rename to setup/bin/setup.exe index 6eaa97e42d5..820aca51a57 100644 Binary files a/Patcher/setup/bin/setup.exe and b/setup/bin/setup.exe differ diff --git a/Patcher/setup/bin/setup.exe.config b/setup/bin/setup.exe.config similarity index 100% rename from Patcher/setup/bin/setup.exe.config rename to setup/bin/setup.exe.config diff --git a/setup/bin/setup.pdb b/setup/bin/setup.pdb new file mode 100644 index 00000000000..0c0acf7c55e Binary files /dev/null and b/setup/bin/setup.pdb differ diff --git a/Patcher/setup/bin/setup.vshost.exe b/setup/bin/setup.vshost.exe similarity index 100% rename from Patcher/setup/bin/setup.vshost.exe rename to setup/bin/setup.vshost.exe diff --git a/Patcher/setup/bin/setup.vshost.exe.config b/setup/bin/setup.vshost.exe.config similarity index 100% rename from Patcher/setup/bin/setup.vshost.exe.config rename to setup/bin/setup.vshost.exe.config diff --git a/Patcher/setup/bin/setup.vshost.exe.manifest b/setup/bin/setup.vshost.exe.manifest similarity index 100% rename from Patcher/setup/bin/setup.vshost.exe.manifest rename to setup/bin/setup.vshost.exe.manifest diff --git a/Patcher/setup/icon/file.png b/setup/icon/file.png similarity index 100% rename from Patcher/setup/icon/file.png rename to setup/icon/file.png diff --git a/Patcher/setup/icon/folder.png b/setup/icon/folder.png similarity index 100% rename from Patcher/setup/icon/folder.png rename to setup/icon/folder.png diff --git a/Patcher/setup/lib/ICSharpCode.Decompiler.dll b/setup/lib/ICSharpCode.Decompiler.dll similarity index 100% rename from Patcher/setup/lib/ICSharpCode.Decompiler.dll rename to setup/lib/ICSharpCode.Decompiler.dll diff --git a/Patcher/setup/lib/ICSharpCode.NRefactory.CSharp.dll b/setup/lib/ICSharpCode.NRefactory.CSharp.dll similarity index 100% rename from Patcher/setup/lib/ICSharpCode.NRefactory.CSharp.dll rename to setup/lib/ICSharpCode.NRefactory.CSharp.dll diff --git a/Patcher/setup/lib/ICSharpCode.NRefactory.dll b/setup/lib/ICSharpCode.NRefactory.dll similarity index 100% rename from Patcher/setup/lib/ICSharpCode.NRefactory.dll rename to setup/lib/ICSharpCode.NRefactory.dll diff --git a/Patcher/setup/lib/ILSpy-license.txt b/setup/lib/ILSpy-license.txt similarity index 100% rename from Patcher/setup/lib/ILSpy-license.txt rename to setup/lib/ILSpy-license.txt diff --git a/Patcher/setup/lib/ILSpy.exe b/setup/lib/ILSpy.exe similarity index 100% rename from Patcher/setup/lib/ILSpy.exe rename to setup/lib/ILSpy.exe diff --git a/Patcher/setup/lib/Mono.Cecil.dll b/setup/lib/Mono.Cecil.dll similarity index 100% rename from Patcher/setup/lib/Mono.Cecil.dll rename to setup/lib/Mono.Cecil.dll diff --git a/Patcher/setup/setup.csproj b/setup/setup.csproj similarity index 100% rename from Patcher/setup/setup.csproj rename to setup/setup.csproj diff --git a/Patcher/setup/setup.csproj.DotSettings b/setup/setup.csproj.DotSettings similarity index 100% rename from Patcher/setup/setup.csproj.DotSettings rename to setup/setup.csproj.DotSettings diff --git a/Patcher/setup/setup.sln b/setup/setup.sln similarity index 100% rename from Patcher/setup/setup.sln rename to setup/setup.sln diff --git a/Patcher/setup/tools/applydiff.exe b/setup/tools/applydiff.exe similarity index 100% rename from Patcher/setup/tools/applydiff.exe rename to setup/tools/applydiff.exe diff --git a/Patcher/setup/tools/diff.py b/setup/tools/diff.py similarity index 100% rename from Patcher/setup/tools/diff.py rename to setup/tools/diff.py diff --git a/Patcher/setup/tools/py.exe b/setup/tools/py.exe similarity index 100% rename from Patcher/setup/tools/py.exe rename to setup/tools/py.exe diff --git a/Patcher/solutions/Terraria.sln b/solutions/Terraria.sln similarity index 100% rename from Patcher/solutions/Terraria.sln rename to solutions/Terraria.sln diff --git a/Patcher/solutions/tModLoader.sln b/solutions/tModLoader.sln similarity index 51% rename from Patcher/solutions/tModLoader.sln rename to solutions/tModLoader.sln index 5dba18e108f..62d7363d3f4 100644 --- a/Patcher/solutions/tModLoader.sln +++ b/solutions/tModLoader.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terraria", "..\src\tModLoader\Terraria.csproj", "{F289741C-268A-484B-9216-822EBBA1A211}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terraria", "..\src\tModLoader\Terraria.csproj", "{3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServer", "..\src\tModLoader\TerrariaServer.csproj", "{BE8168B8-377A-4216-8252-7A302F07C8BA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServer", "..\src\tModLoader\TerrariaServer.csproj", "{85BF1171-A0DC-4696-BFA4-D6E9DC4E0830}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F289741C-268A-484B-9216-822EBBA1A211}.Debug|x86.ActiveCfg = Debug|x86 - {F289741C-268A-484B-9216-822EBBA1A211}.Debug|x86.Build.0 = Debug|x86 - {F289741C-268A-484B-9216-822EBBA1A211}.Release|x86.ActiveCfg = Release|x86 - {F289741C-268A-484B-9216-822EBBA1A211}.Release|x86.Build.0 = Release|x86 - {BE8168B8-377A-4216-8252-7A302F07C8BA}.Debug|x86.ActiveCfg = Debug|x86 - {BE8168B8-377A-4216-8252-7A302F07C8BA}.Debug|x86.Build.0 = Debug|x86 - {BE8168B8-377A-4216-8252-7A302F07C8BA}.Release|x86.ActiveCfg = Release|x86 - {BE8168B8-377A-4216-8252-7A302F07C8BA}.Release|x86.Build.0 = Release|x86 + {3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Debug|x86.ActiveCfg = Debug|x86 + {3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Debug|x86.Build.0 = Debug|x86 + {3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Release|x86.ActiveCfg = Release|x86 + {3996D5FA-6E59-4FE4-9F2B-40EEEF9645D5}.Release|x86.Build.0 = Release|x86 + {85BF1171-A0DC-4696-BFA4-D6E9DC4E0830}.Debug|x86.ActiveCfg = Debug|x86 + {85BF1171-A0DC-4696-BFA4-D6E9DC4E0830}.Debug|x86.Build.0 = Debug|x86 + {85BF1171-A0DC-4696-BFA4-D6E9DC4E0830}.Release|x86.ActiveCfg = Release|x86 + {85BF1171-A0DC-4696-BFA4-D6E9DC4E0830}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE