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 Y = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (
|
using (var reader = database.QueryReader("SELECT X1, Y1, height, width FROM Regions WHERE RegionName=@0 AND WorldID=@1",
|
||||||
var reader = database.QueryReader("SELECT X1, Y1, height, width FROM Regions WHERE RegionName=@0 AND WorldID=@1",
|
|
||||||
regionName, Main.worldID.ToString()))
|
regionName, Main.worldID.ToString()))
|
||||||
{
|
{
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
|
{
|
||||||
X = reader.Get<int>("X1");
|
X = reader.Get<int>("X1");
|
||||||
width = reader.Get<int>("width");
|
width = reader.Get<int>("width");
|
||||||
Y = reader.Get<int>("Y1");
|
Y = reader.Get<int>("Y1");
|
||||||
height = reader.Get<int>("height");
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
switch (direction)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
Y -= addAmount;
|
||||||
|
height += addAmount;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
width += addAmount;
|
width += addAmount;
|
||||||
}
|
break;
|
||||||
|
case 2:
|
||||||
|
height += addAmount;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
X -= addAmount;
|
||||||
|
width += addAmount;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
foreach (var region in Regions.Where(r => r.Name == regionName))
|
||||||
Y -= addAmount;
|
region.Area = new Rectangle(X, Y, width, height);
|
||||||
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,
|
||||||
}
|
|
||||||
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());
|
height, regionName, Main.worldID.ToString());
|
||||||
if (q > 0)
|
if (q > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue