Skip to content

Commit

Permalink
Add protocol support for Terraria 1.4.3.2
Browse files Browse the repository at this point in the history
Adds version support for 1.4.3.2 Terraria servers + maintains compatibility with clients on 1.4.3.1
  • Loading branch information
Moneylover3246 committed Nov 25, 2021
1 parent c08eb0b commit 5fc8971
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
22 changes: 14 additions & 8 deletions Crossplay/CrossplayPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class CrossplayPlugin : TerrariaPlugin
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.6.0");
public override Version Version => new Version("1.7.0");

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

public static string ConfigPath => Path.Combine("tshock", "Crossplay.json");

Expand All @@ -41,6 +41,7 @@ public class CrossplayPlugin : TerrariaPlugin
{ 237, 666 },
{ 238, 667 },
{ 242, 669 },
{ 243, 669 },
};
public static readonly Dictionary<int, int> MaxTileType = new Dictionary<int, int>()
{
Expand All @@ -52,6 +53,7 @@ public class CrossplayPlugin : TerrariaPlugin
{ 237, 623 },
{ 238, 623 },
{ 242, 624 },
{ 243, 624 },
};
public static readonly Dictionary<int, int> MaxBuffType = new Dictionary<int, int>()
{
Expand All @@ -63,6 +65,7 @@ public class CrossplayPlugin : TerrariaPlugin
{ 237, 329 },
{ 238, 329 },
{ 242, 335 },
{ 243, 335 },
};
public static readonly Dictionary<int, int> MaxProjectileType = new Dictionary<int, int>()
{
Expand All @@ -74,6 +77,7 @@ public class CrossplayPlugin : TerrariaPlugin
{ 237, 955 },
{ 238, 955 },
{ 242, 970 },
{ 243, 970 },
};
public static readonly Dictionary<int, int> MaxItemType = new Dictionary<int, int>()
{
Expand All @@ -85,6 +89,7 @@ public class CrossplayPlugin : TerrariaPlugin
{ 237, 5087 },
{ 238, 5087 },
{ 242, 5124 },
{ 243, 5124 },
};

public CrossplayPlugin(Main game) : base(game)
Expand Down Expand Up @@ -274,7 +279,7 @@ private void SendBytes(SendBytesEventArgs args)
byte[] bytes = reader.ReadBytes(22);
string worldName = reader.ReadString();
byte[] bytes2 = reader.ReadBytes(103);
reader.ReadByte(); // Main.tenthAnniversaryWorld
reader.BaseStream.Position++; // bitFlags[8]
byte[] bytes3 = reader.ReadBytes(27);
byte[] worldInfo = new PacketFactory()
.SetType(7)
Expand Down Expand Up @@ -436,7 +441,7 @@ private void SendBytes(SendBytesEventArgs args)
}
Log($"/ ProjectileUpdate - swapped type from {old} -> {projType} from previously exceeded maxType", true, ConsoleColor.DarkGreen);
}
if (playerVersion < 237)
if (playerVersion > 236)
{
return;
}
Expand All @@ -462,14 +467,14 @@ private void SendBytes(SendBytesEventArgs args)
break;
case PacketTypes.NpcUpdate:
{
reader.ReadBytes(20);
reader.BaseStream.Position += 20;
BitsByte npcFlags = reader.ReadByte();
reader.ReadByte();
reader.BaseStream.Position++;
for (int i = 2; i < 6; i++)
{
if (npcFlags[i])
{
reader.ReadSingle();
reader.BaseStream.Position += 4;
}
}
int type = reader.ReadInt16();
Expand All @@ -484,7 +489,6 @@ private void SendBytes(SendBytesEventArgs args)
case PacketTypes.PlayerBuff:
{
var playerId = reader.ReadByte();

var buffWrite = new PacketFactory();
buffWrite.SetType(50);
buffWrite.PackByte(playerId);
Expand Down Expand Up @@ -615,6 +619,8 @@ private string Convert(int version)
return "v1.4.3";
case "Terraria243":
return "v1.4.3.1";
case "Terraria244":
return "v1.4.3.2";
}
return $"Unknown{version}";
}
Expand Down
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.6.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.6.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.7.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.7.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Crossplay")]
[assembly: System.Reflection.AssemblyTitleAttribute("Crossplay")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.6.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.7.0")]

// Generated by the MSBuild WriteCodeFragment class.

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

0 comments on commit 5fc8971

Please sign in to comment.