Merge pull request #1166 from CoderCow/general-devel

Concurrent Dictionary Access Fix
This commit is contained in:
Tyler Watson 2016-02-29 09:02:28 +10:00
commit fc69dccb8b
2 changed files with 15 additions and 9 deletions

View file

@ -2137,8 +2137,9 @@ namespace TShockAPI
{
args.Player.TilePlaceThreshold++;
var coords = new Vector2(tileX, tileY);
if (!args.Player.TilesCreated.ContainsKey(coords))
args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]);
lock (args.Player.TilesCreated)
if (!args.Player.TilesCreated.ContainsKey(coords))
args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]);
}
if ((action == EditAction.KillTile || action == EditAction.KillTileNoItem || action == EditAction.KillWall) && Main.tileSolid[Main.tile[tileX, tileY].type] &&
@ -2146,8 +2147,9 @@ namespace TShockAPI
{
args.Player.TileKillThreshold++;
var coords = new Vector2(tileX, tileY);
if (!args.Player.TilesDestroyed.ContainsKey(coords))
args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY]);
lock (args.Player.TilesDestroyed)
if (!args.Player.TilesDestroyed.ContainsKey(coords))
args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY]);
}
return false;
}
@ -2239,8 +2241,9 @@ namespace TShockAPI
{
args.Player.TilePlaceThreshold++;
var coords = new Vector2(x, y);
if (!args.Player.TilesCreated.ContainsKey(coords))
args.Player.TilesCreated.Add(coords, Main.tile[x, y]);
lock (args.Player.TilesCreated)
if (!args.Player.TilesCreated.ContainsKey(coords))
args.Player.TilesCreated.Add(coords, Main.tile[x, y]);
}
return false;

View file

@ -894,7 +894,8 @@ namespace TShockAPI
{
player.TileKillThreshold = 0;
//We don't want to revert the entire map in case of a disable.
player.TilesDestroyed.Clear();
lock (player.TilesDestroyed)
player.TilesDestroyed.Clear();
}
if (player.TilesCreated != null)
@ -902,8 +903,10 @@ namespace TShockAPI
if (player.TilePlaceThreshold >= Config.TilePlaceThreshold)
{
player.Disable("Reached TilePlace threshold", flags);
TSPlayer.Server.RevertTiles(player.TilesCreated);
player.TilesCreated.Clear();
lock (player.TilesCreated) {
TSPlayer.Server.RevertTiles(player.TilesCreated);
player.TilesCreated.Clear();
}
}
}
if (player.TilePlaceThreshold > 0)