示例#1
0
        public void AddTileban(string regionName, short tileId)
        {
            RtRegion rt = GetRtRegionByName(regionName);

            if (rt == null)
            {
                throw new Exception("Invalid region!");
            }
            if (rt.TileIsBanned(tileId))
            {
                throw new Exception($"Tile {tileId} has been already banned in this region.");
            }

            var modified = new StringBuilder(rt.Tilebans);

            if (modified.Length != 0)
            {
                modified.Append(',');
            }
            modified.Append(tileId);

            if (_database.Query("UPDATE RtRegions SET Tilebans = @0 WHERE Id = @1", modified, rt.Id) == 0)
            {
                throw new Exception("Database error: No affected rows.");
            }

            rt.Tilebans = modified.ToString();
        }
示例#2
0
        public void RemoveTileban(RtRegion rt, short tileId)
        {
            if (!rt.TileIsBanned(tileId))
            {
                return;
            }

            var origin = rt.Tilebans;

            if (rt.RemoveBannedTile(tileId) &&
                _database.Query("UPDATE RtRegions SET Tilebans = @0 WHERE Id = @1", rt.Tilebans, rt.Id) != 0)
            {
                return;
            }

            rt.Tilebans = origin;
            throw new Exception("Database error: No affected rows.");
        }
示例#3
0
        public void AddTileban(RtRegion rt, short tileId)
        {
            if (rt.TileIsBanned(tileId))
            {
                return;
            }

            var modified = new StringBuilder(rt.Tilebans);

            if (modified.Length != 0)
            {
                modified.Append(',');
            }
            modified.Append(tileId);

            _database.Query("UPDATE RtRegions SET Tilebans = @0 WHERE Id = @1", modified, rt.Id);

            rt.Tilebans = modified.ToString();
        }
示例#4
0
        public void RemoveTileban(string regionName, short tileId)
        {
            RtRegion rt = GetRtRegionByName(regionName);

            if (rt == null)
            {
                throw new Exception("Invalid region!");
            }
            if (!rt.TileIsBanned(tileId))
            {
                throw new Exception($"Tile {tileId} is not banned in this region.");
            }
            var origin = rt.Tilebans;

            if (rt.RemoveBannedTile(tileId) &&
                _database.Query("UPDATE RtRegions SET Tilebans = @0 WHERE Id = @1", rt.Tilebans, rt.Id) != 0)
            {
                return;
            }

            rt.Tilebans = origin;
            throw new Exception("Database error: No affected rows.");
        }