Merge remote-tracking branch 'upstream/general-devel' into net9-upgrade

This commit is contained in:
Luke 2025-05-09 22:38:33 +10:00
commit df05e94226
15 changed files with 421 additions and 1293 deletions

View file

@ -63,7 +63,7 @@ namespace TShockAPI
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
/// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary>
public static readonly string VersionCodename = "East";
public static readonly string VersionCodename = "Hopefully SSC works somewhat correctly now edition";
/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
public static string SavePath = "tshock";
@ -1172,16 +1172,16 @@ namespace TShockAPI
if (player.RecentFuse > 0)
player.RecentFuse--;
if ((Main.ServerSideCharacter) && (player.TPlayer.SpawnX > 0) && (player.sX != player.TPlayer.SpawnX))
if (Main.ServerSideCharacter && player.initialSpawn)
{
player.sX = player.TPlayer.SpawnX;
player.sY = player.TPlayer.SpawnY;
}
player.initialSpawn = false;
if ((Main.ServerSideCharacter) && (player.sX > 0) && (player.sY > 0) && (player.TPlayer.SpawnX < 0))
{
player.TPlayer.SpawnX = player.sX;
player.TPlayer.SpawnY = player.sY;
// reassert the correct spawnpoint value after the game's Spawn handler changed it
player.TPlayer.SpawnX = player.initialServerSpawnX;
player.TPlayer.SpawnY = player.initialServerSpawnY;
player.TeleportSpawnpoint();
TShock.Log.ConsoleDebug(GetString("OnSecondUpdate / initial ssc spawn for {0} at ({1}, {2})", player.Name, player.TPlayer.SpawnX, player.TPlayer.SpawnY));
}
if (player.RPPending > 0)
@ -1430,7 +1430,7 @@ namespace TShockAPI
if (tsplr.ReceivedInfo)
{
if (!tsplr.SilentKickInProgress && tsplr.State >= 3 && tsplr.FinishedHandshake) //The player has left, do not broadcast any clients exploiting the behaviour of not spawning their player.
if (!tsplr.SilentKickInProgress && tsplr.State >= (int)ConnectionState.RequestingWorldData && tsplr.FinishedHandshake) //The player has left, do not broadcast any clients exploiting the behaviour of not spawning their player.
Utils.Broadcast(GetString("{0} has left.", tsplr.Name), Color.Yellow);
Log.Info(GetString("{0} disconnected.", tsplr.Name));
@ -1451,7 +1451,6 @@ namespace TShockAPI
}
}
tsplr.FinishedHandshake = false;
// Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object.
@ -1460,8 +1459,8 @@ namespace TShockAPI
Hooks.PlayerHooks.OnPlayerLogout(tsplr);
}
// The last player will leave after this hook is executed.
if (Utils.GetActivePlayerCount() == 1)
// If this is the last player online, update the console title and save the world if needed
if (Utils.GetActivePlayerCount() == 0)
{
if (Config.Settings.SaveWorldOnLastPlayerExit)
SaveManager.Instance.SaveWorld();
@ -1485,6 +1484,7 @@ namespace TShockAPI
if (!tsplr.FinishedHandshake)
{
tsplr.Kick(GetString("Your client didn't send the right connection information."), true);
args.Handled = true;
return;
}
@ -1668,7 +1668,7 @@ namespace TShockAPI
return;
}
if ((player.State < 10 || player.Dead) && (int)type > 12 && (int)type != 16 && (int)type != 42 && (int)type != 50 &&
if ((player.State < (int)ConnectionState.Complete || player.Dead) && (int)type > 12 && (int)type != 16 && (int)type != 42 && (int)type != 50 &&
(int)type != 38 && (int)type != 21 && (int)type != 22 && type != PacketTypes.SyncLoadout)
{
e.Handled = true;