Fix resizeRegion
This commit is contained in:
parent
cefc33eae3
commit
eb8ffe5cfb
1 changed files with 28 additions and 37 deletions
|
|
@ -311,52 +311,43 @@ namespace TShockAPI.DB
|
|||
int Y = 0;
|
||||
int height = 0;
|
||||
int width = 0;
|
||||
|
||||
try
|
||||
{
|
||||
using (
|
||||
var reader = database.QueryReader("SELECT X1, Y1, height, width FROM Regions WHERE RegionName=@0 AND WorldID=@1",
|
||||
using (var reader = database.QueryReader("SELECT X1, Y1, height, width FROM Regions WHERE RegionName=@0 AND WorldID=@1",
|
||||
regionName, Main.worldID.ToString()))
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
X = reader.Get<int>("X1");
|
||||
width = reader.Get<int>("width");
|
||||
Y = reader.Get<int>("Y1");
|
||||
height = reader.Get<int>("height");
|
||||
}
|
||||
if (!(direction == 0))
|
||||
{
|
||||
if (!(direction == 1))
|
||||
{
|
||||
if (!(direction == 2))
|
||||
{
|
||||
if (!(direction == 3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
X -= addAmount;
|
||||
width += addAmount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
height += addAmount;
|
||||
}
|
||||
width = reader.Get<int>("width");
|
||||
Y = reader.Get<int>("Y1");
|
||||
height = reader.Get<int>("height");
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
Y -= addAmount;
|
||||
height += addAmount;
|
||||
break;
|
||||
case 1:
|
||||
width += addAmount;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
height += addAmount;
|
||||
break;
|
||||
case 3:
|
||||
X -= addAmount;
|
||||
width += addAmount;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Y -= addAmount;
|
||||
height += addAmount;
|
||||
}
|
||||
int q =
|
||||
database.Query(
|
||||
"UPDATE Regions SET X1 = @0, Y1 = @1, width = @2, height = @3 WHERE RegionName = @4 AND WorldID=@5", X, Y, width,
|
||||
|
||||
foreach (var region in Regions.Where(r => r.Name == regionName))
|
||||
region.Area = new Rectangle(X, Y, width, height);
|
||||
int q = database.Query("UPDATE Regions SET X1 = @0, Y1 = @1, width = @2, height = @3 WHERE RegionName = @4 AND WorldID=@5", X, Y, width,
|
||||
height, regionName, Main.worldID.ToString());
|
||||
if (q > 0)
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue