public ushort RevertTileType(uint x, uint y, bool sendEvent) { ushort regionId = regionLocator.GetRegionIndex(x, y); ushort tileType; lock (RegionChanges) { IRegion region = GetRegion(x, y); long idx = (regionLocator.GetTileIndex(x, y) * Region.TILE_SIZE) + (Region.TILE_SIZE * RegionSize * regionId); tileType = MapData[idx]; // Check if it's actually changed if (region.GetTileType(x, y) == tileType) { return(tileType); } RegionChanges.Seek(idx, SeekOrigin.Begin); RegionChanges.Write(BitConverter.GetBytes(tileType), 0, 2); RegionChanges.Flush(); region.SetTileType(x, y, tileType); } if (sendEvent && Global.Current.FireEvents) { var packet = new Packet(Command.RegionSetTile); packet.AddUInt16(1); packet.AddUInt32(x); packet.AddUInt32(y); packet.AddUInt16(tileType); channel.Post("/WORLD/" + regionId, packet); } return(tileType); }
public ushort GetTileType(uint x, uint y) { IRegion region = GetRegion(x, y); return(region.GetTileType(x, y)); }