Fixes brace style (#248)

This commit is contained in:
Kamron Batman 2020-09-13 21:49:46 -07:00 • committed by GitHub
parent a236617ad9
commit 8149620b0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1503 changed files with 28575 additions and 1717 deletions

View file

@ -44,25 +44,37 @@ namespace Server.Multis
var map = from.Map;
if (map == null || map == Map.Internal)
{
return HousePlacementResult.BadLand; // A house cannot go here
}
if (from.AccessLevel >= AccessLevel.GameMaster)
{
return HousePlacementResult.Valid; // Staff can place anywhere
}
if (map == Map.Ilshenar || SpellHelper.IsFeluccaT2A(map, center))
{
return HousePlacementResult.BadRegion; // No houses in Ilshenar/T2A
}
if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E))
{
return HousePlacementResult.InvalidCastleKeep;
}
if (Region.Find(center, map).IsPartOf<NoHousingRegion>())
{
return HousePlacementResult.BadRegion;
}
// This holds data describing the internal structure of the house
var mcl = MultiData.GetComponents(multiID);
if (multiID >= 0x13EC && multiID < 0x1D00)
{
HouseFoundation.AddStairsTo(ref mcl); // this is a AOS house, add the stairs
}
// Location of the nortwest-most corner of the house
var start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);
@ -84,6 +96,7 @@ namespace Server.Multis
*/
for (var x = 0; x < mcl.Width; ++x)
{
for (var y = 0; y < mcl.Height; ++y)
{
var tileX = start.X + x;
@ -92,22 +105,30 @@ namespace Server.Multis
var addTiles = mcl.Tiles[x][y];
if (addTiles.Length == 0)
{
continue; // There are no tiles here, continue checking somewhere else
}
var testPoint = new Point3D(tileX, tileY, center.Z);
var reg = Region.Find(testPoint, map);
if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc
if (!reg.AllowHousing(@from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc
{
if (reg.IsPartOf<TempNoHousingRegion>())
{
return HousePlacementResult.BadRegionTemp;
}
if (reg.IsPartOf<TreasureRegion>() || reg.IsPartOf<HouseRegion>())
{
return HousePlacementResult.BadRegionHidden;
}
if (reg.IsPartOf<HouseRaffleRegion>())
{
return HousePlacementResult.BadRegionRaffle;
}
return HousePlacementResult.BadRegion;
}
@ -126,7 +147,9 @@ namespace Server.Multis
var item = sector.Items[i];
if (item.Visible && item.X == tileX && item.Y == tileY)
{
items.Add(item);
}
}
mobiles.Clear();
@ -136,7 +159,9 @@ namespace Server.Multis
var m = sector.Mobiles[i];
if (m.X == tileX && m.Y == tileY)
{
mobiles.Add(m);
}
}
int landStartZ = 0, landAvgZ = 0, landTopZ = 0;
@ -150,7 +175,9 @@ namespace Server.Multis
var addTile = addTiles[i];
if (addTile.ID == 0x1) // Nodraw
{
continue;
}
var addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags;
@ -158,21 +185,29 @@ namespace Server.Multis
var hasSurface = false;
if (isFoundation)
{
hasFoundation = true;
}
var addTileZ = center.Z + addTile.Z;
var addTileTop = addTileZ + addTile.Height;
if ((addTileFlags & TileFlag.Surface) != 0)
{
addTileTop += 16;
}
if (addTileTop > landStartZ && landAvgZ > addTileZ)
{
return HousePlacementResult.BadLand; // Broke rule #2
}
if (isFoundation &&
(TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0 &&
landAvgZ == center.Z)
{
hasSurface = true;
}
for (var j = 0; j < oldTiles.Length; ++j)
{
@ -181,7 +216,10 @@ namespace Server.Multis
if ((id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0) &&
addTileTop > oldTile.Z && oldTile.Z + id.CalcHeight > addTileZ)
{
return HousePlacementResult.BadStatic; // Broke rule #2
}
/*else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z)
hasSurface = true;*/
}
@ -194,9 +232,13 @@ namespace Server.Multis
if (addTileTop > item.Z && item.Z + id.CalcHeight > addTileZ)
{
if (item.Movable)
{
toMove.Add(item);
}
else if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0)
{
return HousePlacementResult.BadItem; // Broke rule #2
}
}
/*else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z)
@ -206,37 +248,52 @@ namespace Server.Multis
}
if (isFoundation && !hasSurface)
{
return HousePlacementResult.NoSurface; // Broke rule #4
}
for (var j = 0; j < mobiles.Count; ++j)
{
var m = mobiles[j];
if (addTileTop > m.Z && m.Z + 16 > addTileZ)
{
toMove.Add(m);
}
}
}
for (var i = 0; i < m_RoadIDs.Length; i += 2)
{
if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1])
{
return HousePlacementResult.BadLand; // Broke rule #5
}
}
if (hasFoundation)
{
for (var xOffset = -1; xOffset <= 1; ++xOffset)
{
for (var yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
{
var yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);
if (!yard.Contains(yardPoint))
{
yard.Add(yardPoint);
}
}
}
for (var xOffset = -1; xOffset <= 1; ++xOffset)
{
for (var yOffset = -1; yOffset <= 1; ++yOffset)
{
if (xOffset == 0 && yOffset == 0)
{
continue;
}
// To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)
@ -254,20 +311,28 @@ namespace Server.Multis
if (breakTile.Height == 0 && breakTile.Z <= 8 &&
TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface)
{
shouldBreak = true;
}
}
if (shouldBreak)
{
continue;
}
}
var borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);
if (!borders.Contains(borderPoint))
{
borders.Add(borderPoint);
}
}
}
}
}
}
for (var i = 0; i < borders.Count; ++i)
{
@ -277,11 +342,17 @@ namespace Server.Multis
var landID = landTile.ID & TileData.MaxLandValue;
if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
{
return HousePlacementResult.BadLand;
}
for (var j = 0; j < m_RoadIDs.Length; j += 2)
{
if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1])
{
return HousePlacementResult.BadLand; // Broke rule #5
}
}
var tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);
@ -292,7 +363,9 @@ namespace Server.Multis
if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0 &&
tile.Z + id.CalcHeight > center.Z + 2)
{
return HousePlacementResult.BadStatic; // Broke rule #1
}
}
var sector = map.GetSector(borderPoint.X, borderPoint.Y);
@ -303,13 +376,17 @@ namespace Server.Multis
var item = sectorItems[j];
if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
{
continue;
}
var id = item.ItemData;
if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0 &&
item.Z + id.CalcHeight > center.Z + 2)
{
return HousePlacementResult.BadItem; // Broke rule #1
}
}
}
@ -325,18 +402,29 @@ namespace Server.Multis
_sectors.Add(sector);
for (var j = 0; j < sector.Multis?.Count; j++)
{
if (sector.Multis[j] is BaseHouse)
{
var _house = (BaseHouse)sector.Multis[j];
if (!_houses.Contains(_house)) _houses.Add(_house);
if (!_houses.Contains(_house))
{
_houses.Add(_house);
}
}
}
}
}
for (var i = 0; i < yard.Count; ++i)
{
foreach (var b in _houses)
{
if (b.Contains(yard[i]))
{
return HousePlacementResult.BadStatic; // Broke rule #3
}
}
}
/*Point2D yardPoint = yard[i];
IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y );