Fixes #1169 on MySQL

This commit is contained in:
White 2016-04-02 11:04:37 +10:30
parent 02e317436e
commit 8bf58dedf4

View file

@ -140,11 +140,18 @@ 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))
{
if (res.Read())
{
id = res.Get<int>("Id");
}
var region = new Region(id, new Rectangle(tx, ty, width, height), regionname, owner, true, worldid, z);
else
{
return false;
}
}
Region region = new Region(id, new Rectangle(tx, ty, width, height), regionname, owner, true, worldid, z);
Regions.Add(region);
Hooks.RegionHooks.OnRegionCreated(region);
return true;