Skip to content

Commit

Permalink
Add support for 1.4.3 Terraria Servers
Browse files Browse the repository at this point in the history
Adds plugin support for 1.4.3 terraria. All players post 1.4 are able to join players with the plugin
  • Loading branch information
Moneylover3246 committed Nov 20, 2021
1 parent b309ab5 commit 4984e53
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 67 deletions.
28 changes: 20 additions & 8 deletions Crossplay/Crossplay.cs → Crossplay/CrossplayPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,30 @@
namespace Crossplay
{
[ApiVersion(2, 1)]
public class Crossplay : TerrariaPlugin
public class CrossplayPlugin : TerrariaPlugin
{
public static int Header = 3;
public override string Name => "Crossplay";
public override string Author => "Moneylover3246";
public override string Description => "Enables crossplay for terraria";
public override Version Version => new Version("1.4.2.1");
public override Version Version => new Version("1.5.0");

private readonly List<int> AllowedVersions = new List<int>() { 230, 233, 234, 235, 236, 237, 238 };

private static List<int> AllowedVersions = new List<int>() { 230, 233, 234, 235, 236, 237 };
public static string ConfigPath => Path.Combine("tshock", "Crossplay.json");

public static CrossplayConfig Config = new CrossplayConfig();

private static readonly int[] ClientVersions = new int[Main.maxPlayers];
private static readonly Dictionary<int, int> MaxNPCID = new Dictionary<int, int>()
private readonly int[] ClientVersions = new int[Main.maxPlayers];
public static readonly Dictionary<int, int> MaxNPCID = new Dictionary<int, int>()
{
{ 230, 662 },
{ 233, 664 },
{ 234, 664 },
{ 235, 664 },
{ 236, 664 },
{ 237, 666 },
{ 238, 667 },
};
public static readonly Dictionary<int, int> MaxTileType = new Dictionary<int, int>()
{
Expand All @@ -47,6 +49,7 @@ public class Crossplay : TerrariaPlugin
{ 235, 623 },
{ 236, 623 },
{ 237, 623 },
{ 238, 623 },
};
public static readonly Dictionary<int, int> MaxBuffType = new Dictionary<int, int>()
{
Expand All @@ -56,6 +59,7 @@ public class Crossplay : TerrariaPlugin
{ 235, 329 },
{ 236, 329 },
{ 237, 329 },
{ 238, 329 },
};
public static readonly Dictionary<int, int> MaxProjectileType = new Dictionary<int, int>()
{
Expand All @@ -65,6 +69,7 @@ public class Crossplay : TerrariaPlugin
{ 235, 955 },
{ 236, 955 },
{ 237, 955 },
{ 238, 955 }
};
public static readonly Dictionary<int, int> MaxItemType = new Dictionary<int, int>()
{
Expand All @@ -74,9 +79,10 @@ public class Crossplay : TerrariaPlugin
{ 235, 5087 },
{ 236, 5087 },
{ 237, 5087 },
{ 238, 5087 },
};

public Crossplay(Main game) : base(game)
public CrossplayPlugin(Main game) : base(game)
{
Order = -1;
}
Expand Down Expand Up @@ -153,7 +159,7 @@ private void GetData(GetDataEventArgs args)
.SetType(1)
.PackString($"Terraria{Main.curRelease}")
.GetByteData();
Log($"Changing version of index {args.Msg.whoAmI} from {Convert(version)} => v1.4.2.3", color: ConsoleColor.Green);
Log($"Changing version of index {args.Msg.whoAmI} from {Convert(version)} => {Convert(Main.curRelease)}", color: ConsoleColor.Green);

Buffer.BlockCopy(connectRequest, 0, args.Msg.readBuffer, args.Index - 3, connectRequest.Length);
}
Expand Down Expand Up @@ -254,6 +260,10 @@ private void SendBytes(SendBytesEventArgs args)
{
case PacketTypes.WorldInfo:
{
if (playerVersion >= 238)
{
return;
}
byte[] bytes = reader.ReadBytes(22);
string worldName = reader.ReadString();
byte[] bytes2 = reader.ReadBytes(103);
Expand Down Expand Up @@ -585,8 +595,10 @@ private string Convert(int version)
return "v1.4.2.2";
case "Terraria238":
return "v1.4.2.3";
case "Terraria242":
return "v1.4.3";
}
return "";
return $"Unknown{version}";
}

public static void Log(string message, bool debug = false, ConsoleColor color = ConsoleColor.White)
Expand Down
4 changes: 2 additions & 2 deletions Crossplay/SectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SectionHelper
{
public static byte[] WriteDecompressedSection(MemoryStream decompressionStream, int version)
{
int maxTileType = Crossplay.MaxTileType[version];
int maxTileType = CrossplayPlugin.MaxTileType[version];
using (BinaryReader reader = new BinaryReader(decompressionStream))
{
BinaryWriter writer = new BinaryWriter(decompressionStream);
Expand Down Expand Up @@ -61,7 +61,7 @@ public static byte[] WriteDecompressedSection(MemoryStream decompressionStream,
}
writer.BaseStream.Position -= 2;
writer.Write((ushort)newType);
Crossplay.Log($"/ SendSection - Processed a tile conversion from {(typeLong << 8) | typeShort} -> {newType}", true, ConsoleColor.Red);
CrossplayPlugin.Log($"/ SendSection - Processed a tile conversion from {(typeLong << 8) | typeShort} -> {newType}", true, ConsoleColor.Red);
}
}
else
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions Crossplay/obj/Release/net40/Crossplay.AssemblyInfo.cs

This file was deleted.

6 changes: 3 additions & 3 deletions Crossplay/obj/Release/net45/Crossplay.AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

[assembly: System.Reflection.AssemblyCompanyAttribute("Crossplay")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.5.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.5.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Crossplay")]
[assembly: System.Reflection.AssemblyTitleAttribute("Crossplay")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.5.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
is_global = true
build_property.RootNamespace = Crossplay
build_property.ProjectDir = C:\Users\Evan\Downloads\Crossplay\Crossplay\

This file was deleted.

23 changes: 0 additions & 23 deletions Crossplay/obj/Release/net472/Crossplay.AssemblyInfo.cs

This file was deleted.

Binary file modified References/OTAPI.dll
Binary file not shown.
Binary file modified References/TShockAPI.dll
Binary file not shown.
Binary file modified References/TerrariaServer.exe
Binary file not shown.

1 comment on commit 4984e53

@X15964623340
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

666

Please sign in to comment.