Fixed bug in AddRegion failing to completely add regions

An invalid SQL query selecting the region ID from the newly inserted
region prevented the AddRegion method from completely adding a region,
even though it was inserted into the database correctly, leading to a
`false` result even though the region add was successful.

This fixes /region define, and HouseRegions.
This commit is contained in:
Tyler Watson 2016-02-06 20:37:57 +10:00
parent 1bf703a6b0
commit 3d37f51290

View file

@ -140,7 +140,7 @@ namespace TShockAPI.DB
"INSERT INTO Regions (X1, Y1, width, height, RegionName, WorldID, UserIds, Protected, Groups, Owner, Z) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10);",
tx, ty, width, height, regionname, worldid, "", 1, "", owner, z);
int id;
using (QueryResult res = database.QueryReader("SELECT Id FROM Regions WHERE RegionName = @0 AND WorldID = @1", regionname, worldid))
using (QueryResult res = database.QueryReader("SELECT Id FROM Regions WHERE RegionName = '@0' AND WorldID = '@1'", regionname, worldid))
{
id = res.Get<int>("Id");
}