Fix doors in the lamest way possible (!)

Fixes #1774.

This commit is designed to fix the clientside door desync issue. Based
on the order of events that I've been able to see, the way that door
opening works is like this:

1. Client sends a door open request.
2. Server echoes request back to client.
3. Both server and client simulate door opening.
4. The client that requests the initial door open sends a tile square to
the server for some reason.

In TShock, under all circumstances, we send a tile square back to the
client that sends one in, unless you have the
`tshock.ignore.sendtilesquare` permission. This adds a deviation: it
does not network data back if the event is just a door change. Doing
this is safe from the perspective of actual gameplay. A previous
iteration of this commit synchronized data to other clients, but that
seemed superfluous.

This does not really solve the underlying problem or answer the question
as to why sending a tile square back to the client seems to throw it
off, but it does. I was not able to replicate the desync issue anymore
with this branch. I expect that it will be safe to keep, because the
improved logic will only happen if the tile square had no effective
changes in addition to the door changes.
This commit is contained in:
Lucas Nicodemus 2020-05-30 23:43:51 -07:00
parent 3f0e51080b
commit ac76ccf589
No known key found for this signature in database
GPG key ID: A07BD9023D1664DB
2 changed files with 9 additions and 1 deletions

View file

@ -560,6 +560,7 @@ namespace TShockAPI
bool changed = false;
bool failed = false;
bool doorRelated = false;
try
{
var tiles = new NetTile[size, size];
@ -591,6 +592,11 @@ namespace TShockAPI
continue;
}
if (newtile.Active && Terraria.ID.TileID.Sets.RoomNeeds.CountsAsDoor.Contains(newtile.Type))
{
doorRelated = true;
}
// Fixes the Flower Boots not creating flowers issue
if (size == 1 && args.Player.Accessories.Any(i => i.active && i.netID == ItemID.FlowerBoots))
{
@ -704,7 +710,8 @@ namespace TShockAPI
}
else
{
args.Player.SendTileSquare(tileX, tileY, size);
if (!doorRelated)
args.Player.SendTileSquare(tileX, tileY, size);
}
}
catch